In the end, your real problem is that using %hash in list context results in resetting the iterator in each.
Or dereferencing a reference to %hash in list context. E.g.:
>perl -wMstrict -le "my %hash = qw(a 1 b 2 c 3); my $hashref = \%hash; ;; for (1 .. 3) { my ($k) = each %$hashref; print qq{'$k' => '$hashref->{$k}'}; my @ra = %$hashref; } " 'c' => '3' 'c' => '3' 'c' => '3'
Comment out the
my @ra = %$hashref;
statement for more-expected behavior.
In reply to Re^2: subroutine reference parameters
by AnomalousMonk
in thread subroutine reference parameters
by dnajjar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |