|more useful options|
getopts and -?by viffer (Beadle)
|on May 10, 2011 at 01:08 UTC||Need Help??|
viffer has asked for the wisdom of the Perl Monks concerning the following question:
I'm converting a shell script to perl. The shell script has a number of switches passed to it, one being "-?".
Using "getopts" I can cater for all the various switches *except* the -?.
I can't use a variable '$opt_?' as it gives a syntax error.
I tried to list the various switches then use $ARGV[0}to pick up the -? if it was supplied, but having the '-', in front of the question mark, makes getopts look for a switch, rather than treating it as $ARGV[0}.
Is there any way I can pass "-?" as an option for getopts?
I'm calling the script via
Removing the dash preceding the question mark in the command isn't an option, neither is using something other than "-?".
If I knew the "-?" would always be first I could put the check for -? in $ARGV[0} before the getops command, but I don't know what order the switches will be provided in so that's not an option either.
Also I don't have control over the command line so can't use a double dash on the command line to let the script know the options are finished and that -? is now $ARGV[0}
Any help your collective wisdom can offer up will be greatly appreciated.