UPDATED
For the reason that the array is coming in from user input (Getopt::Long), so I don't want to add unknown options to my final hash.
I want to pare down the entries in the hash to the mimimum amount of keys corresponding to only known parameters that i have been given.
cheers though,
Sorry the first draft of this reply was gibberish
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;