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
Yes its possible. This works for me.
my @a = ();
my $aref = \@a; # creates a reference to the array a
push(@$aref, "somevalue"); # dereference $aref and push somevalue in it
print $a[0]; # print the just pushed value, again @$aref[0] should also work
As has been mentioned, $aref = [@a] will copy and not create reference to a