I am trynig to receive a hash by reference within my subroutine
sub usefulfacts{
print "Inside usefulfacts\n";
my $localhash=@_;
my %tmphash=%{$localhash};
foreach my $k (keys(%tmphash)){ print "$tmphash($k)"."\n" ;}
}
And it is called as
#now we send in a hash to modify by reference
%gim=(
"environ"=>"challenging",
"strength"=>"mental",
"tough"=>"persistent"
);
foreach my $k (keys(%gim)){ print "$tmphash($k)"."\n" ;}
usefulfacts(\%gim);
The has h is not getting printed inside the subroutine;though it prints successfulyl in the main body.Whats wrong?
Also,if i need to dereference a individual entry in teh hash ,how do i do it?
sub usefulfacts{
print "Inside usefulfacts\n";
my $localhash=@_;
my %tmphash=%{$localhash};
foreach my $k (keys(%tmphash)){ print "$tmphash($k)"."\n" ;}
}
And it is called as
#now we send in a hash to modify by reference
%gim=(
"environ"=>"challenging",
"strength"=>"mental",
"tough"=>"persistent"
);
foreach my $k (keys(%gim)){ print "$tmphash($k)"."\n" ;}
usefulfacts(\%gim);
The has h is not getting printed inside the subroutine;though it prints successfulyl in the main body.Whats wrong?
Also,if i need to dereference a individual entry in teh hash ,how do i do it?