in reply to Populating Hash passed to a sub as reference
Oh, you're so very close! Try the following, instead:
use strict; use warnings; use Data::Dumper; sub PopulateHash { my $hashParm = shift; %$hashParm = ( 1 => 'a', 2 => 'b', 3 => 'c', 4 => 'd'); print Dumper(\%$hashParm); } my %hash = (); PopulateHash(\%hash); print Dumper(\%hash);
Output:
$VAR1 = { '4' => 'd', '1' => 'a', '3' => 'c', '2' => 'b' }; $VAR1 = { '4' => 'd', '1' => 'a', '3' => 'c', '2' => 'b' };
Just use the dereferenced parm that was sent to populate your hash...
|
|---|