in reply to subroutine reference parameters
each returns two things, key and value. You only assign to $key. You probably wanted to use keys instead? Or this:
sub printElement { my ($key,$val) = @_; print $key,' ',$val,"\n"; } my %hash = (0 => 'a', 1 => 'b', 2 => 'c'); while(my ($key,$value) = each(%hash)) { &printElement($key, $value); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: subroutine reference parameters
by gnosti (Chaplain) on Jun 04, 2011 at 01:38 UTC | |
by choroba (Cardinal) on Jun 04, 2011 at 09:54 UTC |
In Section
Seekers of Perl Wisdom