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

It's been a long time since I've got my hands dirty with Perl, so forgive me if this question seems elementary. I am hitting the second if() from this code block when running the below line from the command prompt. Any help would be much appreciated.
my ($db,$killswitch,$configDepth,$hostname) #default values = (0 ,0 ,-1 ,''); GetOptions( 'v!' => \$db , 'k!' => \$killswitch , 'd=i'=> \$configDepth , 'H=s'=> \$hostname ); if( $configDepth == -1){ print $0.' requires the -d switch with a dept +h value.'.$cr; die; } if( $hostname == '' ){ print $0.' requires the -H with a hostname or + comma-seperated list of hostnames.'.$cr; die;}

And here is the line:
$>traverse.pl -v -H WSTM0165815 -d=1 C:\depot\code\util\pl\traverse.pl requires the -H with a hostname or c +omma-seperated list of hostnames. Died at C:\depot\code\util\pl\traverse.pl line 34.
amt.

perlcheat

Replies are listed 'Best First'.
Re: Getopt::Long Help with Mandatory String Opt
by ikegami (Patriarch) on Aug 10, 2010 at 19:59 UTC
    Use warnings! You're checking for numerical equivalence (==) instead of string equivalence (eq).
      It is apparent that my script-fu has become very weak. Have an upvote.
      amt.

      perlcheat