awohld has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my %hash; # don't want these keys in the subroutine $hash{'ytd'} = 1.5; $hash{'mtd'} = 2.0; $hash{'wtd'} = 2.5; # store what I don't want here my @do_not_want = qw{ ytd mtd wtd }; # want these keys and any others in subroutine $hash{'Jumbo_Tron'} = "United Center"; $hash{'Meat_Pie'} = "Gross"; $hash{'Word'} = "Association"; # my try, grepping each item in @do_not_want into a larger grep foreach my $anything_but ( grep { grep { }, @do_not_want }, keys %hash + ) { # print every key except for "ytd", "mtd", and "wtd" print $anything_but . "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Selecting a Specific Keys in Relation to a List
by GrandFather (Saint) on Nov 01, 2007 at 03:07 UTC | |
Re: Selecting a Specific Keys in Relation to a List
by artist (Parson) on Nov 01, 2007 at 03:07 UTC | |
Re: Selecting a Specific Keys in Relation to a List
by Anonymous Monk on Nov 01, 2007 at 05:32 UTC | |
Re: Selecting a Specific Keys in Relation to a List
by tuxz0r (Pilgrim) on Nov 01, 2007 at 17:54 UTC | |
by TGI (Parson) on Nov 01, 2007 at 19:32 UTC | |
by tuxz0r (Pilgrim) on Nov 02, 2007 at 03:38 UTC | |
by TGI (Parson) on Nov 02, 2007 at 18:33 UTC |