What does \@array mean in Perl? What does \@array mean in Perl? arrays arrays

What does \@array mean in Perl?


the \@ notation will return a reference (or pointer) to the array provided, so:

$arrayref = \@array

will make $arrayref a reference to @array - this is similar to using the *p pointer notation in C.


It means it's a reference to an array.

See the perl documentation that explains it well


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].