in reply to Using GetOpt::Std to parse switches with arguments

I'd go with Getopt::Long.

The difference between the two isn't that drastic, but Long is far more configurable and powerful (IMHO), making your task trivial...

my $ok = GetOptions( \%args, 'i=s', 'o=s', 'w=i', 's=i', 'help|?', ); usage() if ! $ok || $args{'help'};

That still allows an all-digit filename, but you can handle those with ...

foreach my $opt (qw( i o )) { usage() unless $args{$opt} =~ /\D/; }

... if you really think that should be disallowed.

Also, if you take advantage of Getopt::Long's auto-abbreviation feature (which is on by default), then you can give your switches more meaningful names (ie, 'input=s') for use within your script and still have the shorter, 'initials-only' forms work.

    --k.


Replies are listed 'Best First'.
Re: Re: Using GetOpt::Std to parse switches with arguments
by EyeOpener (Scribe) on Apr 19, 2002 at 21:40 UTC
    Thanks, all. Looks like Getopt::Long is going to be the way to go. Time to read the docs... :-)

    Have a great weekend!