in reply to Re: do something if hash keys match regex
in thread do something if hash keys match regex

... $1 is not available when the RHS is evaluated.

Just as a side note, it's worse. Captures from a previous successful match are available:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "'keep your powder dry' =~ /(pow)/; ;; $_ = 'a_b_c'; ;; my %h; $h{ (/a_(.*)_c/)[0] } = qq{boom_$1}; ;; dd \%h; " { b => "boom_pow" }
And we glimpse the protean form of a nasty bug.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: do something if hash keys match regex
by kcott (Archbishop) on Jul 22, 2017 at 01:56 UTC

    Yes, his code zooms towards doom and goes boom. :-)

    — Ken