in reply to .= $err_msg

i'd do something like:
#!/usr/bin/perl -w use strict; use Getopt::Long; my( $username, $password, $group ); my %params = ( 'u=s' => \$username, 'p=s' => \$password, 'g=s' => \$group, ); sub usage { die << "USAGE"; Usage: $0 -u username -p password -g group [-others] Description: whatever... USAGE } usage() unless( GetOptions( %params ) ); for( values %params ) { usage() unless defined ${ $_ }; }

~Particle *accelerates*

Replies are listed 'Best First'.
Re: Re: .= $err_msg
by chip (Curate) on Apr 27, 2002 at 06:04 UTC
    That last loop just begs for trimming:

    grep { not defined $$_ } values %params or die usage();

    Well, maybe it's just me. But I really think that judicious grep usage is much clearer than equivalent for loops.

        -- Chip Salzenberg, Free-Floating Agent of Chaos