Is there a way to get Perl to avoid treating negative values as command-line switches? Neither stringifying nor backslashing the argument seems to help under Linux:
$ perl -e 'print "@ARGV\n";' 4 5
4 5
$ perl -e 'print "@ARGV\n";' -4 5
Unrecognized switch: -4 (-h will show valid options).
$ perl -e 'print "@ARGV\n";' "-4" 5
Unrecognized switch: -4 (-h will show valid options).
$ perl -e 'print "@ARGV\n";' '-4' 5
Unrecognized switch: -4 (-h will show valid options).
$ perl -e 'print "@ARGV\n";' \-4 5
Unrecognized switch: -4 (-h will show valid options).
The trick is using the double-hyphen (
--) to end the option parsing. Double-hyphen is a GNU convention: