perl-5.38.0
pop ARRAY
pop

Removes and returns the last element of the array, shortening the array by one element.

配列の 最後の 値を削除して返し、配列の大きさを 1 だけ小さくします。

    my @arr  = ('cat', 'dog', 'mouse');
    my $item = pop(@arr); # 'mouse'

    # @arr is now ('cat', 'dog')

Returns undef if the array is empty.

配列が空なら undef を返します。

Note: pop may also return undef if the last element in the array is undef.

Note: pop may also return undef if the last element in the array is undef. (TBT)

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

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

ARRAY が省略されると、pop は、メインプログラムでは @ARGV が使われますが、 サブルーチンでは @_ が使われます。 popeval STRING, BEGIN {}, INIT {}, CHECK {} ブロックの中で @ARGV を操作します。

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.

Perl 5.14 から、pop がスカラ式を取ることが出来るという 実験的機能がありました。 この実験は失敗と見なされ、Perl 5.24 で削除されました。