http://qs1969.pair.com?node_id=683881


in reply to Using Getopt::Long and prompting for arguments

From the CPAN description of GetOpt::Long, for variables which can take a value:

"In the option specification, the option name is followed by an equals sign = and the letter s. The equals sign indicates that this option requires a value. The letter s indicates that this value is an arbitrary string. Other possible value types are i for integer values, and f for floating point values. Using a colon : instead of the equals sign indicates that the option value is optional. In this case, if no suitable value is supplied, string valued options get an empty string '' assigned, while numeric options are set to 0."

So if you set the value to be optional, and if a user does not enter a filename, the value of $user_wants{CUSTOM_SAVE_PLACE} will be ''.

if ((defined $user_wants{CUSTOM_SAVE_PLACE}) && ($user_wants{CUSTOM_SA +VE_PLACE} == '')){ print "Please enter a save location\n"; ..etc. }


edit:added 'if defined'
........
Those are my principles. If you don't like them I have others.
-- Groucho Marx
.......