You are viewing the version of this documentation from Perl 5.29.0. This is a development version of Perl.
$PERL_VERSION
$^V

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

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.

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

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:

printf "version is v%vd\n", $^V;  # Perl's version

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

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

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, whereas the behavior of $] is unchanged on all versions of Perl.

Mnemonic: use ^V for a version object.