An excerpt from the documentation:

"
      my $tag = '';       # option variable with default value
      GetOptions ('tag=s' => \$tag);

  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..."







-----Original Message-----
From: Chris Knipe [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 07, 2005 7:38 PM
To: beginners@perl.org
Subject: Getopt::Long

Hi all,
 
Just a quick question and a couple of lines of really simple code.... 
 
use Getopt::Long;
 
...
 
GetOptions ('h'   => \$h,
            'b=s' => \$s );

Sub ShowHelp() {
  print "this is help"
}

Sub DoSomethingWithString() {
...
}

If ($s) {
  DoSomethingWithString();
} else {
  ShowHelp();
}
 
Right.  Now, whilst the above is not perhaps 100% correct, it goes about
a
generality of Getopt::Long.

If I now run the application,
./blah.pl -h   - I get the help screen
./blah.pl -s   - I get a error, complaining that -s requires a value,
and
THEN the help screen.
./blah.pl -s s - Everything is fine.

So, this is more of a block question I think, but how I can get the
above
example to show the help screen FIRST, and THEN complain about the
missing
value for -s ????

Thanks,
 
 
--
Regards,
Chris.
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to