I tried to find an elegant way to avoid map...grep
Roger's first solution actually does this in a pretty nice way. I added some formatting to [hopefully] make it more clear, but here's his code:
my %hashslice1 = map { /^NETWORK/ ? ($_, $hash{$_}) : ( ) } keys %hash;
Even still, I can see how mixing the selection of the keys with the hashification is a bit confusing, so that's why I gave a map {} grep {} solution that separates them.
In reply to Re: Re: Re: Hash slices
by revdiablo
in thread Hash slices
by Marcello
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |