1. Perl
  2. builtin functions
  3. here

pop function - extracts the last element of an array

Use the pop function to retrieve the last element of the array .

$last = pop @array;

Example

This is an example of the pop function. If @nums is (1, 2, 3), 3 is assigned to $last and @nums becomes (1, 2).

my @nums = (1, 2, 3);
my $last = pop @nums;

Related Informatrion