GetOptions::Long question


A

aether8203

I am trying to use GetOptions in such a way that if the user does not
provide the correct mandatory arguments, the usage sub is called. The
problem is that even when I call it correctly, it is going into the
usage() sub. Can you see anything from the example below?

# parse command line args
{
my $show_usage = 0;
Getopt::Long::config('bundling');
GetOptions(
'h|help' => \$show_usage,
'l|location=s' => \$location,
'b|base=s' => \$base
) or $show_usage = 1;

if ($show_usage == 1) { usage(); exit 64 }

}

sub usage() {
print <<EOF;

Usage: $0 .... etc
EOF
}
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top