Perl: the Markov chain saw | |
PerlMonks |
Re: do something if hash keys match regexby shmem (Chancellor) |
on Jul 20, 2017 at 08:44 UTC ( [id://1195571]=note: print w/replies, xml ) | Need Help?? |
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
which arguably isn't as readable as your current solution.
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
In Section
Seekers of Perl Wisdom
|
|