in reply to Re: subroutine reference parameters
in thread subroutine reference parameters
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.
|
|---|