perl-5.38.0
wantarray

Returns true if the context of the currently executing subroutine or eval is looking for a list value. Returns false if the context is looking for a scalar. Returns the undefined value if the context is looking for no value (void context).

現在実行中のサブルーチンか eval ブロックのコンテキストが、 リスト値を要求するものであれば、真を返します。 スカラを要求するコンテキストであれば、偽を返します。 何も値を要求しない(無効コンテキスト)場合は未定義値を返します。

    return unless defined wantarray; # don't bother doing more
    my @a = complex_calculation();
    return wantarray ? @a : "@a";

wantarray's result is unspecified in the top level of a file, in a BEGIN, UNITCHECK, CHECK, INIT or END block, or in a DESTROY method.

ファイルのトップレベル、BEGIN, UNITCHECK, CHECK, INIT, END ブロック内、DESTROY メソッド内では wantarray の結果は 未定義です。

This function should have been named wantlist() instead.

この関数は wantlist() という名前にするべきでした。