Simply test the keys against your pattern:
foreach my $key ( keys %hash ) { if( $key =~ m/\d+_\d+/ ) { print "key = $key, value = $hash{$key}\n"; } }
Or am I missing something?
HTH
Update: I forgot about the "modify hash" requirement - sorry. merlyn came up with a great one-liner, of course!
In reply to Re: Selecting particular key-value pairs in hashes
by bobf
in thread Selecting particular key-value pairs in hashes
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |