in reply to Selecting a Specific Keys in Relation to a List

You really want that reject list as a hash. Consider:

my @do_not_want = qw{ ytd mtd wtd }; my %rejects; @rejects{@do_not_want} = (); foreach my $anything_but ( grep {! exists $rejects{$_}} keys %hash ) { print $anything_but . "\n"; }

which in the context of the rest of your sample prints:

Meat_Pie Jumbo_Tron Word

The magic bit is @rejects{@do_not_want} = (); which uses a hash slice (see Slices) to create a hash with an entry for each unique element in @do_not_want.

Update: provided better hash slice link


Perl is environmentally friendly - it saves trees