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:
Expand|Select|Wrap|Line Numbers
- 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";
- }
Expand|Select|Wrap|Line Numbers
- 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)
- ....
Expand|Select|Wrap|Line Numbers
- 0: author = XXXXXXXXXXX
- # where XXXXXXXXX is the author in the first hash map.
Expand|Select|Wrap|Line Numbers
- # inside of a while loop:
- my $hash = {
- author => $temp[0],
- train => $temp[1],
- fileName => $temp[2],
- };
- push(@input,\$hash);