What does \@array mean in Perl?
Array references are primarily useful as parameters to subroutines. Without references, passing the array @a
(with the elements 1,2,3) is pretty much the same as passing 1, 2, and 3 separately to the sub. With \@array
, the sub can see the entire array, e.g. determine its length explicitly, manipulate it so that the caller can sees the changes, etc. The price for that power is that the sub has to use more complicated syntax when accessing the array elements: $$a[0]
instead of $a[0]
.