in reply to Strange behavior of array in scalar context
This puts whatever happens to be returned on the right-hand side into the first slot of the array @executions. It just happens that what you get is from the RHS not an empty array, but an empty arrayref. And this arrayref happens to occupy the first slot of the array @executions. Therefore, the array @executions has one element.
See what print Dumper \@executions; returns instead.
To turn an arrayref into an array (i.e. copy its contents to an array), you need to dereference it, or you can just keep using it as an arrayref. I usually do the latter.
# Dereference and copy contents my @executions = @{ $jobInfo->{'content'}{'executions'} }; # Just use it as an arrayref my $executions = $jobInfo->{'content'}{'executions'}; print scalar @$executions, "\n"; print "element 0 is ", $executions->[0], "\n";
|
|---|