<?xml version="1.0" encoding="windows-1252"?>
<node id="789690" title="problem using foreach and each with hash ref" created="2009-08-19 01:41:08" updated="2009-08-19 01:41:08">
<type id="115">
perlquestion</type>
<author id="734134">
vinoth.ree</author>
<data>
<field name="doctext">
&lt;c&gt; use strict;
use warnings;
use Data::Dumper;
my $hash_ref={1002=&gt;[1,2,3,4,5],1001=&gt;[6,7,8,9,10],3=&gt;[2]};
my ($key,$val);
foreach(($key,$val)=each %$hash_ref){
    print "Each()=======================&gt;$key=&gt;$val&lt;=======================\n";
    print "Default&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;$_&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\n";
}
&lt;/c&gt;

&lt;p&gt;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! &lt;/p&gt;

&lt;b&gt;Update&lt;/b&gt;
&lt;p&gt;Title changed.&lt;/p&gt;</field>
</data>
</node>
