# destructive /\d+_\d+/ or delete $hash{ $_ } while local $_ = each %hash; # nondestructive my %hash2; /\d+_\d+/ and $hash2{ $_ } = $a while local( $_, $a ) = each %hash;