note
Punitha
<p>Hi [isha],</p>
<p>If you want to manipulate the simple hash, then your hash will be like this,</p>
<c>my %myhash = ( 1 => 'a', 2=> 'b', 3=> 'a', 4=>'c');</c>
<p>To manipulate this simple hash, you can do like</p>
<c>
use strict;
my %myhash = ( 1 => 'a', 2=> 'b', 3=> 'a', 4=>'c');
for my $key (keys %myhash){
if($myhash{$key} eq 'a'){
print "KEY:$key\n";
}
}</c>
<p>But you created the hash as</p>
<c>
my %myhash = { 1 => 'a', 2=> 'b', 3=> 'a', 4=>'c'};
</c>
<p>which is anonymous hash reference. To manipulate this hash reference, then you can do like</p>
<c>use strict;
my $myhash = { 1 => 'a', 2=> 'b', 3=> 'a', 4=>'c'};
for my $key (keys %{$myhash}){
if(${$myhash}{$key} eq 'a'){
print "KEY:$key\n";
}
}</c>
<p>Punitha</p>
660756
660756