- 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
undefif the array is empty.配列が空なら
undefを返します。Note:
popmay also returnundefif the last element in the array isundef.注意:
popは、配列の最後の要素がundefの場合もundefを 返します。my @arr = ('one', 'two', undef); my $item = pop(@arr); # undefIf ARRAY is omitted,
popoperates on the@ARGVarray in the main program, but the@_array in subroutines.popwill operate on the@ARGVarray ineval STRING,BEGIN {},INIT {},CHECK {}blocks.ARRAY が省略されると、
popは、メインプログラムでは@ARGVが使われますが、 サブルーチンでは@_が使われます。popはeval STRING,BEGIN {},INIT {},CHECK {}ブロックの中で@ARGVを操作します。Starting with Perl 5.14, an experimental feature allowed
popto 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 で削除されました。