Is it possible to push
to an array reference in Perl? Googling has suggested I deference the array first, but this doesn\'t really work. It pushes to the defere
$a
is not $a_ref
, ($a
is the first comparison variable given to a sort{}
, and $a[0]
is the 0th element of the @a
array).Never use $a
, or $b
outside of a custom sort subroutine, and the @a
and @b
array should probably be avoided to too (there are plenty of better choices)...
What you're doing is assigning to $a_ref
, an anonymous array, and then pushing onto it "hello"
, but printing out the first element of the @a
array.