... $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:
And we glimpse the protean form of a nasty bug.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" }
Give a man a fish: <%-{-{-{-<
In reply to Re^2: do something if hash keys match regex
by AnomalousMonk
in thread do something if hash keys match regex
by anandk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |