- 论坛徽章:
- 0
|
回复 1# rick_7
An array is a defined area of storage for list values, so we can generate a reference to it with the
backslash operator:
$arrayref = \@array;
This produces a reference through which the original array can be accessed and manipulated.
Alternatively, we can make a copy of an array and assign that to a reference by using the array
reference constructor (also known as the anonymous array constructor) [...]:
$copyofarray = [@array];
Both methods give us a reference to an anonymous array that we can assign to, delete from, and modify.
The distinction between the two is important, because one will produce a reference that points to the
original array, and so can be used to pass it to subroutines for manipulations on the original data,
whereas the other will create a copy that can be modified separately. |
|