in reply to Re: Re: Hash slices
in thread Hash slices
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Hash slices
by QM (Parson) on Feb 17, 2004 at 23:45 UTC |