If I do the following, it works fine:
print $ref->{element}->[0]->{data};
I would like to see how many references are in the array so that I can loop through them, but I am having a hard time doing that.
Here is the code I have tried, but it doesn’t work:
my @array = @$ref->{element};
foreach(@array) {
print $_->{data};
}
I get an “Not an ARRAY reference” error
Hashes of lists are tricky that way.
@$ref->{element}gets parsed as(@$ref)->{element}, dereferencing$refinstead of$ref->{element}.Try
or
Gory details in perllol.