in reply to Re: Mapping array over a hash
in thread Mapping array over a hash
my %opts; my %locs = map { $_ => 1 } ('do', 'ny', 'kw'); my %sect = ('uid' => 1, 'email' => 'a', 'username' => 'a'); my $USAGE = qq( USAGE: perl launch.pl (-l=<location>)+ (-d=<data>)+ Where -l=<location> = [do|kw|ny] = one or more times -d=<data_type> = [uid|email|username] = one or more times ); die $USAGE unless (scalar(@ARGV) >= 2); GetOptions(\%opts, "l=s@", "d=s@"); die $USAGE unless (defined $opts{'l'}); die $USAGE unless (defined $opts{'d'}); %locs = map { $_ => $locs{$_}} grep defined $locs{$_}, @{ $opts{'l'} +}; # strips out keys from hash if %sect = map { $_ => $sect{$_}} grep defined $sect{$_}, @{ $opts{'d'} +}; # not requested by user die $USAGE unless scalar keys %locs > 0; die $USAGE unless scalar keys %sect > 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Mapping array over a hash
by dragonchild (Archbishop) on Jul 20, 2001 at 18:09 UTC |