Consider this simple perl program:
#!/usr/bin/perl -s
print "ARGV: @ARGV\n";
print "arg: $arg\n";
Now run it:
chmod u+x test.pl
./test.pl -arg=works
The output is:
ARGV:
arg: works
Running the program in the debugger works, too:
perl -d test.pl -arg=works
Loading DB routines from perl5db.pl version 1.53
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(./test.pl:3): print $arg, "\n";
DB<1> c
ARGV: <-- SEE HERE
arg: works <-- SEE HERE
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> q
However the argument will no longer be parsed if an include path is added:
perl -I . -d test.pl -arg works
Loading DB routines from perl5db.pl version 1.53
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(./test.pl:3): print $arg, "\n";
DB<1> c
ARGV: test.pl -arg=works <-- OOPS
arg: <-- OOPS
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> q
When -I is used @ARGV does not seem to processed the same way. It is like the -s option no longer works as it is supposed to consume switches like -opt=value. Why is that?
Getopt::Long and Getopt::std both work just fine in all cases.
I thought for some time Perl extension in Visual Studio Code did not work correctly.
perl -I . -d test.pl -arg works, but not withperl -I. -d test.pl -arg works(Note the lack of space between the-Iand its argument). Odd.