如果你自己写了一个perl脚本,指定传入参数,如:xxxscript.pl -f <filename> -s <string>
则可以通过下面的代码解决:
#------------------------------------------------------------------------- # 解析输入参数 sub process_args { while (@ARGV) { $a = shift @ARGV; if ($a eq "-h") { Usage(); } elsif ($a eq "-f") { $file= shift @ARGV; } elsif ($a eq "-s") { $string= shift @ARGV ; } else { Usage(); } } }