GetOptions::Long question

Discussion in 'Perl Misc' started by aether8203@yahoo.com, Jun 1, 2005.

  1. Guest

    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
    }
     
    , Jun 1, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    755
    Eric Sosman
    Jul 8, 2003
  2. Moti Shtrobach

    Using GetOptions twice in the script

    Moti Shtrobach, Nov 25, 2003, in forum: Perl Misc
    Replies:
    6
    Views:
    164
    Johan Vromans
    Dec 3, 2003
  3. perl_newbie
    Replies:
    7
    Views:
    202
    A. Sinan Unur
    Jun 2, 2005
  4. a
    Replies:
    1
    Views:
    258
    -berlin.de
    Feb 21, 2007
  5. Tom Gur

    Errormsgs on GetOptions

    Tom Gur, Dec 17, 2007, in forum: Perl Misc
    Replies:
    1
    Views:
    93
    Paul Lalli
    Dec 17, 2007
Loading...

Share This Page