in reply to do something if hash keys match regex

There is no way to select hash keys with a regular expression other than iterating over the keys, be that done with a for/foreach loop, map, or a statement modifier. So, no, you can't do that without using foreach and braces.

But you could stuff your regular expression components into another hash, to avoid repeating yourself inside the foreach loop

my %re = ( boom => [ qw( abc ghi) ], doom => [ qw( mmm nnn) ], zapp => [ qw( xxx yyy) ], ); foreach my $key (keys %hash) { $key =~ /$re{$_}->[0]_(.*)_$re{$_}->[1]/ and $hash{$key} = $_.$1 for keys %re; }

which arguably isn't as readable as your current solution.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'