in reply to do something if hash keys match regex

You won't get much better than the foreach solution, which has the advantage of being easy to read. You could use grep to select the keys: $hash{$_} = "boom_$1" for grep /abc_(.*)_ghi/, keys %hash;

I think the way you generate your data is a bit to complex to be turned into a readable map generation: my %hash = { /abc_(.*)_ghi/ ? ($_ => "boom_$1") : ($_ => 1) } @list_of_keys; wouldn't work so well with the two (or more) separate conditions, or wouldn't be as readable as your current solution.