The revision, version, and subversion of the Perl interpreter, represented as aversion 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 aversion 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, usesprintf()
'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 ofuse VERSION
andrequire 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.
Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.
The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.