Good Morning!
I am a perl newbie and I think that I am struggling with references.
I have an array of references to hashes which I am trying to print. This is what I have:
And it prints:
I want to print:
I am not sure if this is enough info to tell you what is happening. I guess I should include the code for where I am filling the array of ref to hashes.
Thank you in advance for the help. I appreciate it.
I am a perl newbie and I think that I am struggling with references.
I have an array of references to hashes which I am trying to print. This is what I have:
Code:
for(my $i=0; $i<@input; $i++){ my $hash = $input[$i]; print "$i: \n"; print "\t".'$hash = '; print $hash; print "\n\t".'${$hash} = '; print ${$hash}; print "\n\t"; # print ${$hash}{author}; <- THIS DOES NOT WORK WHY? print "\n"; }
Code:
0: $hash = REF(0x180e024) ${$hash} = HASH(0x180b3e4) 1: $hash = REF(0x180da94) ${$hash} = HASH(0x180b198) 2: $hash = REF(0x180e1c8) ${$hash} = HASH(0x180109c) 3: $hash = REF(0x180e21c) ${$hash} = HASH(0x180e288) ....
Code:
0: author = XXXXXXXXXXX # where XXXXXXXXX is the author in the first hash map.
Code:
# inside of a while loop: my $hash = { author => $temp[0], train => $temp[1], fileName => $temp[2], }; push(@input,\$hash);
Comment