Hi,
I am somewhat novice to Perl world. I was trying to write a sub which takes Hash as reference and populate the hash (passed as reference). But when I try to dump the data of the Hash I didn't get any output. Below is the code which I tried to do so
use strict;
use warnings;
use Data::Dumper;
sub PopulateHash {
my $hashParm = shift;
my %hash1 = %$hashParm;
%hash1 = (
1 => 'a',
2 => 'b',
3 => 'c',
4 => 'd');
print Dumper(\%hash1);
}
my %hash = ();
PopulateHash(\%hash);
print Dumper(\%hash);
The output of above code is given below
$VAR1 = {
'4' => 'd',
'1' => 'a',
'3' => 'c',
'2' => 'b'
};
$VAR1 = {};
As this hash will be used at many places so I don't want to have a copy to avoid overheads.
Any pointers about where I am missing will be great.