Rhys has asked for the wisdom of the Perl Monks concerning the following question:

From perlrun:

(-s) enables rudimentary switch parsing for switches on the command line after the program name but before any filename arguments (or before an argument of --). This means you can have switches with two leading dashes (--help). Any switch found there is removed from @ARGV and sets the corresponding variable in the Perl program. The following program prints "1" if the program is invoked with a -xyz switch, and "abc" if it is invoked with xyz=abc.

#!/usr/bin/perl -s if ($xyz) { print "$xyz\n" }

Do note that --help creates the variable ${-help}, which is not compliant with "strict refs".

Now, this last thing is really enough for me. I use strict in just about everything I write that I intend to actually use, since it has found about a zillion things that I've done wrong in the past.

People also pointed out that using -s is pretty much a giant security hole and can lead to the unanticipated creation of strange and interesting variables. Another compelling argument (to me, anyway) is that the docs themselves call this a 'rudimentary switch parsing' method, whereas Getopt::Std and Getopt::Long are more complete ways of doing this.

So what? Where's the question? Right here: There's a guy in my office who likes -s. He says that the first time he did a Google search on using command-line arguments with Perl, a link to an article that suggested -s was the top hit. He also says that since he is the only one that uses his scripts and because he does validation on the variables so passed, the security risks are moot.

So does anyone have a really strong reason NOT to use -s? It seems both kludgy and dangerous to me, but I'm not having fun trying to convince him. Any advice is welcome.