=over

=item pop ARRAY
X<pop> X<stack>

=item pop

Removes and returns the B<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')

Returns C<undef> if the array is empty.

B<Note:> C<pop> may also return C<undef> if the last element in the array
is C<undef>.

    my @arr  = ('one', 'two', undef);
    my $item = pop(@arr); # undef

If ARRAY is omitted, C<pop> operates on the L<C<@ARGV>|perlvar/@ARGV> array
in the main program, but the L<C<@_>|perlvar/@_> array in subroutines. C<pop>
will operate on the C<@ARGV> array in C<eval STRING>, C<BEGIN {}>, C<INIT {}>,
C<CHECK {}> blocks.

Starting with Perl 5.14, an experimental feature allowed
L<C<pop>|/pop ARRAY> to take a
scalar expression. This experiment has been deemed unsuccessful, and was
removed as of Perl 5.24.

=back