1. Perl
  2. builtin functions
  3. shift

shift function - get the beginning of the array

Use the shift function to get the first element of the array . Note that the first element is truncated and is no longer in the original array.

$ret = shift @array;

Example

This is an example shift function. If @nums is (1, 2, 3), 1 is assigned to $first and @nums is (2, 3).

my @nums = (1, 2, 3);
my $first = shift @nums;

Related Informatrion