- shift ARRAY
- shift
-
Removes and returns the first element of an array. This shortens the array by one and moves everything down.
配列の 最初の 値を削除して返します。 配列を一つ短くして、すべての要素を前へずらします。
my @arr = ('cat', 'dog'); my $item = shift(@arr); # 'cat' # @arr is now ('dog');Returns
undefif the array is empty.配列が空なら
undefを返します。Note:
shiftmay also returnundefif the first element in the array isundef.注意:
shiftは、配列の最初の要素がundefの場合もundefを 返します。my @arr = (undef, 'two', 'three'); my $item = shift(@arr); # undefIf ARRAY is omitted,
shiftoperates on the@ARGVarray in the main program, and the@_array in subroutines.shiftwill operate on the@ARGVarray ineval STRING,BEGIN {},INIT {},CHECK {}blocks.ARRAY が省略されると、
shiftはメインプログラムでは@ARGV配列を、 サブルーチンでは@_配列を操作します。shiftはeval STRING,BEGIN {},INIT {},CHECK {}ブロックでは@ARGV配列を操作します。Starting with Perl 5.14, an experimental feature allowed
shiftto take a scalar expression. This experiment has been deemed unsuccessful, and was removed as of Perl 5.24.Perl 5.14 から、
shiftがスカラ式を取ることが出来るという 実験的機能がありました。 この実験は失敗と見なされ、Perl 5.24 で削除されました。See also unshift, push, and pop.
shiftand unshift do the same thing to the left end of an array that pop and push do to the right end.unshift、push、 pop も参照してください。
shiftと unshift は、 pop と push が配列の右端で 行なうことを、左端で行ないます。