perl-5.22.1
$OLD_PERL_VERSION
$]

The revision, version, and subversion of the Perl interpreter, represented as a decimal of the form 5.XXXYYY, where XXX is the version / 1e3 and YYY is the subversion / 1e6. For example, Perl v5.10.1 would be "5.010001".

The revision, version, and subversion of the Perl interpreter, represented as a decimal of the form 5.XXXYYY, where XXX is the version / 1e3 and YYY is the subversion / 1e6. For example, Perl v5.10.1 would be "5.010001". (TBT)

This variable can be used to determine whether the Perl interpreter executing a script is in the right range of versions:

スクリプトの最初で、そのスクリプトを実行しているインタプリタのバージョンが 適切な範囲内にあるかを調べる、といったことができます:

    warn "No PerlIO!\n" if $] lt '5.008';

When comparing $], string comparison operators are highly recommended. The inherent limitations of binary floating point representation can sometimes lead to incorrect comparisons for some numbers on some architectures.

When comparing $], string comparison operators are highly recommended. The inherent limitations of binary floating point representation can sometimes lead to incorrect comparisons for some numbers on some architectures. (TBT)

See also 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 "$^V" for a representation of the Perl version as a version object, which allows more flexible string comparisons.

See "$^V" for a representation of the Perl version as a version object, which allows more flexible string comparisons. (TBT)

The main advantage of $] over $^V is that it works the same on any version of Perl. The disadvantages are that it can't easily be compared to versions in other formats (e.g. literal v-strings, "v1.2.3" or version objects) and numeric comparisons can occasionally fail; it's good for string literal version checks and bad for comparing to a variable that hasn't been sanity-checked.

The main advantage of $] over $^V is that it works the same on any version of Perl. The disadvantages are that it can't easily be compared to versions in other formats (e.g. literal v-strings, "v1.2.3" or version objects) and numeric comparisons can occasionally fail; it's good for string literal version checks and bad for comparing to a variable that hasn't been sanity-checked. (TBT)

The $OLD_PERL_VERSION form was added in Perl v5.20.0 for historical reasons but its use is discouraged. (If your reason to use $] is to run code on old perls then referring to it as $OLD_PERL_VERSION would be self-defeating.)

The $OLD_PERL_VERSION form was added in Perl v5.20.0 for historical reasons but its use is discouraged. (If your reason to use $] is to run code on old perls then referring to it as $OLD_PERL_VERSION would be self-defeating.) (TBT)

Mnemonic: Is this version of perl in the right bracket?

記憶法: Perl のバージョンは、正しい範囲 (right bracket) にあるか。