Perl script on Widows10 can't get command line parameters

Viewed 567

Perl script on Windows 10 can't get command line parameters if command line does not begin with "perl". The same works correctly on Windows7. Please look at example:

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.
0 Answers
Related