pop ARRAY
pop
This function treats an array like a stack - it pops
and returns the last value of the array, shortening the array by 1.
If
ARRAY
is omitted, the function pops @ARGV (in the main program),
or @_ (in subroutines).
It has the same effect as:
$tmp = $ARRAY[$#ARRAY--];
or:
$tmp = splice @ARRAY, -1;
If there are no elements in the array, pop returns the undefined value. See also push and shift. If you want to pop more than one element, use splice.
Note that pop requires its first argument to be an array, not a list. If you just want the last element of a list, use this:
(something_returning_a_list)[-1]