IMHO something like hgrep() or hmap() should be somewhere in the core-moduls... with a code-prototype it's easy to accomplish.
Anyway TIMTOWTDI:
Without explicit grep
%hash_2= map { /regex/ ? ( $_ , $hash_1{$_} ) : () } keys %hash_1;
Hashslice:
my @keys = grep { /regex/ } keys %hash_1; @hash_2{@keys} = @hash_1{@keys};
http://www.perl-community.de/bat/poard/message/120873
Cheers Rolf
In reply to Re: grep for hash?
by LanX
in thread grep for hash?
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |