When you extract an array slice, the subscript can be a literal list of
values, an array, or a perl expression which will result in an array.
Thus, the following statements will all extract an array slice
consisting of the first three elements of the array values
:
@one = @values[0,1,2]; @vals = (0,1,2); @two = @values[@vals]; @three = @values[0..2];
You can also use an array slice on the left-hand side of an assignment statement, allowing you to replace multiple values in an array with a single statement.