... without introducing a new variable ...
The following variation doesn't introduce a new variable because $_ already exists! (I believe the following is also Stupid Hash Trick #58.)
>perl -wMstrict -le "for ({ qw(a 1 b 2 c 3) }) { while (my ($k, $v) = each %$_) { print qq{$k => $v}; } } " c => 3 a => 1 b => 2
In reply to Re^3: Iterating over verbatim hash reference
by AnomalousMonk
in thread Iterating over verbatim hash reference
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |