vinoth.ree has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use Data::Dumper; my $hash_ref={1002=>[1,2,3,4,5],1001=>[6,7,8,9,10],3=>[2]}; my ($key,$val); foreach(($key,$val)=each %$hash_ref){ print "Each()=======================>$key=>$val<================== +=====\n"; print "Default>>>>>>>>>>>>>>>>$_<<<<<<<<<<<<<<<<<<\n"; }
I just tried to get the pair of key and value from the hash reference, I got what I want using the while loop, when I go for 'foreach' I count not understand what is happening ? Any idea pl!
UpdateTitle changed.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: What is happening ?
by tilly (Archbishop) on Aug 19, 2009 at 05:48 UTC | |
by vinoth.ree (Monsignor) on Aug 19, 2009 at 05:56 UTC | |
by goeb (Pilgrim) on Aug 19, 2009 at 06:06 UTC | |
by vinoth.ree (Monsignor) on Aug 19, 2009 at 06:12 UTC | |
by ikegami (Patriarch) on Aug 19, 2009 at 14:38 UTC | |
by grizzley (Chaplain) on Aug 19, 2009 at 08:11 UTC | |
| |
by tilly (Archbishop) on Aug 19, 2009 at 06:08 UTC | |
by vinoth.ree (Monsignor) on Aug 19, 2009 at 06:15 UTC | |
Re: What is happening ?
by Marshall (Canon) on Aug 19, 2009 at 09:37 UTC | |
Re: problem using foreach and each with hash ref
by sanku (Beadle) on Aug 21, 2009 at 12:34 UTC |
Back to
Seekers of Perl Wisdom