我有一些链接的输入,我想打开该链接.例如,我有一个HTML文件,想要查找文件中的所有链接,并在Excel电子表格中打开它们的内容.
我在我的驱动器中有一个名为"Lib"的文件夹,里面包含很多文件,我有一个问题,这个"Lib"文件夹在驱动器的许多其他位置.我的Perl脚本必须复制最新更新的文件夹"Lib"中的内容并将其粘贴到"d:\ perl\Latest_copy_of_Lib"文件夹中
例如,我有一个库文件夹d:\functions,d:\abc和许多其他地方.我想在这些目录中找到每个文件的最新副本.因此,如果文件d:\functions\foo.txt是在2009-10-12上次修改并且在2009-10-13 d:\abc\foo.txt上次修改,那么我希望将版本中d:\abc的内容复制到目标目录.
我使用了file :: find但它在整个目录中搜索并复制了不是最新副本的内容.
我有一段时间,如果,ifif语句在一个文件中有多个条件...它是一个C语言...下面提到的格式是所有多个条件的标准.所以不用担心压力.只有问题是检查有多少条件,并根据我描述的输出格式列出....例如,如果我的C文件有代码...
while(
condition1 &&
condition2 ||
condition3
)
{
#statements;
}
Run Code Online (Sandbox Code Playgroud)
我想计算内部有多少条件,我的输出应该是
这样的......
while(
1 condition1 &&
2 condition2 ||
3 condition3
)
{
#statements;
}
Run Code Online (Sandbox Code Playgroud)
我写了代码,它适用于简单的...我的代码....
open(A,"e:\\a\\a.txt")or die;
@a=<A>;
close(A);
$count=1;
for($i=0;$i<scalar@a;$i++)
{
if($a[$i]=~m/while/g)
{
$line=$i;
until($a[$line]=~/\{/g)
{
if($a[$line]=~/(.*)[\&&\||]/g){print"$count $a[$line]";$count++;}
elsif($a[$line]=~/\(.*\)[\&&\||]/g){print"$count $a[$line]";$count++;}
else{print$a[$line];}
$line++;
}
}
last if($a[$line]=~/\{/g);
}
Run Code Online (Sandbox Code Playgroud)
但对于复杂的条件,如
while(
(
condition1 &&
condition2 &&
condition3
) ||
(
condition4 ||
condition5 &&
condition6
)
{
#statements;
}
Run Code Online (Sandbox Code Playgroud)
我得到的输出像
while(
(
1 condition1 &&
2 condition2 &&
condition3 …Run Code Online (Sandbox Code Playgroud) ^\s*[)]*\s*$ 并^\s*[(]*\s*$匹配括号(和)粗体.也就是说,我想要的是忽略单个而不是(condition1)括号的括号:
while
( #matches here
( #matches here
(condition1) && (condition2) &&
condition3
) ||
(#matches here
(condition4) ||
condition5 &&
(condition6)
) #matches here
) #matches here
Run Code Online (Sandbox Code Playgroud)
但如果我喜欢这个,它就不匹配:
while
(( #does not match here
(condition1) && (condition2) &&
condition3
) ||
(
(condition4) ||
condition5 &&
(condition6)
) ) #does not match here
Run Code Online (Sandbox Code Playgroud)
要么
while
((( #does not match here
(condition1) && (condition2) &&
condition3
)) ||
(( #does not match here …Run Code Online (Sandbox Code Playgroud) 我有一个Excel工作表,并能够使用Perl 将其转换为.csv格式.我唯一的问题是Excel表单元格中的一些数据包含逗号,并且也必须以CSV格式保留,但转换时它需要作为分隔符.如何使用逗号检索单元格中的数据并将其打印在CSV中?
例如,在Excel工作表A1单元格中包含数据,{0xAAAA,0xFFFF,0xAAAA,0xAAAA}我想A1在CSV文件中的单元格中使用逗号相同的数据.我是Spreadsheet :: ParseExcel.
如何将数组的全部内容存储到标量变量.例如:
my $code = do { local $/; <FILE HANDLE>; };
Run Code Online (Sandbox Code Playgroud)
这适用于文件句柄,但我需要这个数组.