perl-5.38.0
unshift ARRAY,LIST

Add one or more elements to the beginning of an array. This is the opposite of a shift.

一つまたは複数の要素を配列の 先頭 に追加します。 これは shift の逆操作です。

    my @animals = ("cat");
    unshift(@animals, "mouse"); # ("mouse", "cat")

    my @colors = ("red");
    unshift(@colors, ("blue", "green")); # ("blue", "green", "red")

Returns the new number of elements in the updated array.

更新された配列の要素の数を返します。

    # Return value is the number of items in the updated array
    my $color_count = unshift(@colors, ("yellow", "purple"));

    say "There are $color_count colors in the updated array";

Note the LIST is prepended whole, not one element at a time, so the prepended elements stay in the same order. Use reverse to do the reverse.

LIST は、はらばらにではなく、一度に登録されるので、順番はそのままです。 逆順に登録するには、reverse を使ってください。

Starting with Perl 5.14, an experimental feature allowed unshift to take a scalar expression. This experiment has been deemed unsuccessful, and was removed as of Perl 5.24.

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