Given a HoHoA
my %FIELDS = (
LA => {
NAME => [1],
ADDRESS => [2,3,4,5],
TYPE => [6],
LICENCE => [0],
ACTIVE => [],
},
...
);
I'm trying to make a copy of a particular array
my @ADDRESS_FIELDS = @{$FIELDS{$STATE}->{ADDRESS} };
Since everything inside %FIELDS is by reference the arrow de-references the inner hash and the @{} de-references the array. (I understand that the arrow isn't strictly necessary)
print $ADDRESS_FIELDS[3]."\n";
print @ADDRESS_FIELDS."\n";
gives
5
4
The first print behaves as expected but the second one is giving me the scalar value of, I assume, the referenced array instead of a new copy. Where am I going astray?
4is indeed just the array evaluated in scalar context, which yields the number of elements. Maybe you were looking forprint "@ADDRESS_FIELDS\n"?