Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: subroutine reference parameters

by AnomalousMonk (Archbishop)
on Jun 03, 2011 at 17:30 UTC ( [id://908029]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://908029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found