use strict;
my $anon = [1,3,5,7,9];
my $aref = [\$anon];
print "3rd element: " . $ { $aref } [2] . "\n";
I'd like to get the nth element of the anonymous array $anon
over the $aref
variable. In the code I wanted to get the 3rd element of $anon
by making the index 2 but it returned nothing. If I write $ { $aref } [0]
then it returns something like REF(0x7fd459027ac0)
How can I get the nth, for example the 3rd element of $anon
?
Rationale:
my @area = (
qw[1 3 5 7 9],
qw[2 4 6 8 0],
qw[a e i u o],
qw[b c d f g]
);
foreach my $row (@area) {
foreach my $cell (@$row)
{
# do some processing on the element
print $cell . " ";
}
print "\n";
}