是否可以在Perl中启用/禁用基于ARGV的使用严格/警告?
我尝试了这段代码,但它不起作用.我认为它应该在'$ x = 2'的行中产生警告错误;
# Do this at the beginning of the script
BEGIN {
if ( $ARGV[0] =~ /^Y$/i ) {
use strict;
use warnings;
}
else {
no strict;
no warnings;
}
}
$x = 2;
print "x is $x\n";
Run Code Online (Sandbox Code Playgroud)
目的是仅在开发中启用警告消息.
我正在使用AIX Korn shell来执行一个Perl脚本,该脚本接受1到50之间的数字参数并同时在后台运行它们.有没有办法像5那样限制后台进程?如果一个完成,执行下一个.我当前的代码只是在后台执行所有代码.
i=1; while [[ $i -le 50 ]]; do perl some_script.pl $i &; ((i+=1)); done;
Run Code Online (Sandbox Code Playgroud)
例如,如果2结束,则执行下一个6,依此类推.