perl-5.22.1
$PERL_VERSION
$^V

The revision, version, and subversion of the Perl interpreter, represented as a version object.

version オブジェクトとして表現される Perl インタプリタの revision, version, subversion。

This variable first appeared in perl v5.6.0; earlier versions of perl will see an undefined value. Before perl v5.10.0 $^V was represented as a v-string rather than a version object.

この変数は perl v5.6.0 で最初に現れました; それより前のバージョンでは 未定義値となります。 perl v5.10.0 以前では $^Vversion オブジェクトではなく v-string 形式で表現されます。

$^V can be used to determine whether the Perl interpreter executing a script is in the right range of versions. For example:

$^V はスクリプトを実行している Perl インタプリタのバージョンが 正しい範囲に入っているかを調べるのに使えます。 例えば:

    warn "Hashes not randomized!\n" if !$^V or $^V lt v5.8.1

While version objects overload stringification, to portably convert $^V into its string representation, use sprintf()'s "%vd" conversion, which works for both v-strings or version objects:

While version objects overload stringification, to portably convert $^V into its string representation, use sprintf()'s "%vd" conversion, which works for both v-strings or version objects: (TBT)

    printf "version is v%vd\n", $^V;  # Perl's version
    printf "version is v%vd\n", $^V;  # Perl のバージョン

See the documentation of use VERSION and require VERSION for a convenient way to fail if the running Perl interpreter is too old.

実行する Perl インタプリタが古すぎる場合に終了する便利な方法については use VERSIONrequire VERSION のドキュメントを参照して下さい。

See also $] for a decimal representation of the Perl version.

Perl バージョンの 10 進表現については $] も参照して下さい。

The main advantage of $^V over $] is that, for Perl v5.10.0 or later, it overloads operators, allowing easy comparison against other version representations (e.g. decimal, literal v-string, "v1.2.3", or objects). The disadvantage is that prior to v5.10.0, it was only a literal v-string, which can't be easily printed or compared.

The main advantage of $^V over $] is that, for Perl v5.10.0 or later, it overloads operators, allowing easy comparison against other version representations (e.g. decimal, literal v-string, "v1.2.3", or objects). The disadvantage is that prior to v5.10.0, it was only a literal v-string, which can't be easily printed or compared. (TBT)

Mnemonic: use ^V for a version object.

記憶法: ^V をバージョンオブジェクトに使います。