#!/usr/bin/perl
use Data::Dumper;
sub giveMeARef {
my %hash = %{$_[0]};
print "arg: ", Dumper($_[0]);
print "deref: ", Dumper(%hash);
}
my %hash = ( "a" => (1,2,3), "b" => (3,4,5));
giveMeARef(\%hash);
This produces the following output:
arg: $VAR1 = {
'2' => 3,
'4' => 5,
'a' => 1,
'b' => 3
};
deref: $VAR1 = 'b';
$VAR2 = 3;
$VAR3 = '2';
$VAR4 = 3;
$VAR5 = 'a';
$VAR6 = 1;
$VAR7 = '4';
$VAR8 = 5;
I tried to follow the examples in How do I dereference a Perl hash reference that's been passed to a subroutine?
But I believe because my hash is more complicated, it isn't working out for me. How do I get back to the original structure I passed in?