techman2006 has asked for the wisdom of the Perl Monks concerning the following question:
The output of above code is given belowuse 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);
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.$VAR1 = { '4' => 'd', '1' => 'a', '3' => 'c', '2' => 'b' }; $VAR1 = {};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Populating Hash passed to a sub as reference
by Kenosis (Priest) on Oct 24, 2013 at 18:48 UTC | |
|
Re: Populating Hash passed to a sub as reference
by GotToBTru (Prior) on Oct 24, 2013 at 19:11 UTC | |
|
Re: Populating Hash passed to a sub as reference
by Anonymous Monk on Oct 25, 2013 at 00:46 UTC |