my %new_hash=(); grep { $_ =~ $my_regexp && $new_hash{$_}=$original_hash($_) } keys %original_hash;