如果命令行不是以“ perl”开头,则Windows 10上的Perl脚本无法获取命令行参数。在Windows7上同样可以正常工作。请查看示例:
D:\>ver
Microsoft Windows [Version 10.0.17763.503]
D:\>assoc .pl
.pl=PerlScript
D:\>ftype PerlScript
PerlScript=D:\x\perl\perl\bin\perl.exe "%1" %*
D:\>type tst.pl
# tst.pl
use strict ;
use warnings ;
print '$0 = '. $0 ."\n" ;
unless( $ARGV[ 0 ] ) { die "No args.\n\n" }
my $i = 0 ;
for my $arg ( @ARGV ) { print $i++ .': '. $arg ."\n" }
D:\>perl tst.pl
$0 = tst.pl
No args.
D:\>perl tst.pl FIRST SECOND
$0 = tst.pl
0: FIRST
1: SECOND
D:\>tst.pl FIRST SECOND
$0 = D:\tst.pl
No args.