Home > Software design >  Force Perl to stop special processing of command line arguments if -e eval switch is used
Force Perl to stop special processing of command line arguments if -e eval switch is used

Time:10-09

perl -e 'print(123, @ARGV);' a b
# 123ab

perl -e 'print(123, @ARGV);' --help
# prints Perl's help instead

This is a toy example demonstrating the problem. In my real use-case I'm using -e to execute a large script from an embedded interpreter using perl_parse(...) function, the script has its own processing of --help switch, so I'd like to block any special processing of command line arguments after -e.

Is it possible?

CodePudding user response:

Use a double hyphen to stop argument processing:

$ perl -e'print "[@ARGV]\n"' -- --help
[--help]
$
  • Related