an invalid option is one that you don't expect the user to enter or
one that is actually not in a valid form? consider the following(foo.pl):
#!/usr/bin/perl -w
use strict;
use Getopt:Long;
$SIG{__WARN__} = sub { print "WARNING WARNING\n"; };
sub process{
print "BAD: ",shift,"\n";
}
my $h;
GetOptions('abcd=s' => \$h, '<>' => \&process);
__END__
if you call foo.pl like:
foo.pl hello --paul
you will get:
BAD: hello
WARNING WARNING
the "BAD: hello" line is caused by the invalid form of option parameter
"hello" and the "WARNING WARNING" line is caused by the "--paul" invalid
command line option which the script doesn't expect to catch.
david
Paul Tremblay wrote:
> I would like to have my script print a short help message and then
> quit if a user uses an invalid option. I am using the Getopt::Long
> module.
>
> Also, I've noticed that some scripts have a trick whereby if a user
> types
>
> scriptname --help
>
> The script prints on the pod. There is a link on perldoc.com for
> usage::pod, but this link is broken.
>
> (I read your tutorial, Drieux, but it was a bit too advanced for me!)
>
> Thanks
>
> Paul
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]