nysus has asked for the wisdom of the Perl Monks concerning the following question:
Surely there's a more efficient way than my hackish two-step code. Perhaps nest the grep inside the map:my %hash = (tom => 23, larry=> 't0', tina=> 23); my @filteredhash = grep{/^t/} keys %hash; my %newhash = map{$_, $hash{$_}} @filteredhash;
That seems a little weird too. Help me out and I'll buy you a beer at the 19th hole.my %newhash = map{$_, $hash{$_}} grep{/^t/} keys %hash;
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop";
$nysus = $PM . $MCF;
Click here if you love Perl Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Miniature golf question
by suaveant (Parson) on Jul 16, 2001 at 22:52 UTC | |
by nysus (Parson) on Jul 16, 2001 at 23:01 UTC | |
|
Re: Miniature golf question
by MeowChow (Vicar) on Jul 16, 2001 at 22:59 UTC | |
by suaveant (Parson) on Jul 16, 2001 at 23:02 UTC | |
|
Re: Miniature golf question
by chipmunk (Parson) on Jul 16, 2001 at 23:27 UTC | |
by tilly (Archbishop) on Jul 17, 2001 at 00:16 UTC | |
by nysus (Parson) on Jul 17, 2001 at 07:30 UTC | |
by suaveant (Parson) on Jul 16, 2001 at 23:31 UTC |