for my $key ( keys %hash_1 ) { $hash_2{$key} = $hash_1{$key} if $key =~ /regex/; }