# destructive while( my $k = each %hash ) { delete $hash{ $k } unless $k =~ /\d+_\d+/; } # nondestructive my %hash2; while( my( $k, $v ) = each %hash ) { $hash2{ $k } = $v if $k =~ /\d+_\d+/; }