I think I prefer toolic's computation of $key as a separate step (more readable/maintainable), but if you really need it all in one statement:
(Note that I use qq{...} instead of "..." only to avoid distracting \ escapes on the Windows command line.)c:\@Work\Perl>perl -wMstrict -le "my $v = { R3R3_foo_IF => 'xyzzy', R3R3_bar_IF => 'wibble', }; ;; my $pic = 'foo'; ;; print qq{whatever $v->{ qq{R3R3_${pic}_IF} } and so on}; " whatever xyzzy and so on
Update: The trick is to realize that $v->{ qq{R3R3_${pic}_IF} } is really $v->{ EXPR } where EXPR is any expression whatsoever (but not a statement). So $v->{ qq{R3R3_${pic}_IF} } evaluates to a scalar which is double-quote-ishly interpolated as usual.
Give a man a fish: <%-{-{-{-<
In reply to Re: variable inside hash key
by AnomalousMonk
in thread variable inside hash key
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |