Removes and returns the last element of the array, shortening the array by one element.
my @arr = ('cat', 'dog', 'mouse'); my $item = pop(@arr); # 'mouse' # @arr is now ('cat', 'dog')
undef if the array is empty.
pop may also return
undef if the last element in the array is
my @arr = ('one', 'two', undef); my $item = pop(@arr); # undef
Starting with Perl 5.14, an experimental feature allowed
pop to take a scalar expression. This experiment has been deemed unsuccessful, and was removed as of Perl 5.24.