To ensure a script has at least version X of perl, you can do the following
require 5.6.8;
What is the best way of checking that a version is not too recent? (i.e. version 5.8.x if fine, but 5.9 or 5.10 are not ok).
To ensure a script has at least version X of perl, you can do the following
require 5.6.8;
What is the best way of checking that a version is not too recent? (i.e. version 5.8.x if fine, but 5.9 or 5.10 are not ok).
This code will die if the version of Perl is greater than 5.8.9:
die "woah, that is a little too new" unless $] <= 5.008009;
You can read more about $]
in perldoc perlvar
.
You can use the special $^V
variable to check the version. From perldoc perlvar:
$^V
The revision, version, and subversion of the Perl interpreter, represented as a
version object.
This variable first appeared in perl 5.6.0; earlier versions of perl will see an
undefined value. Before perl 5.10.0 $^V was represented as a v-string.
You can use $^V in a string comparison, e.g.
if ( $^V lt 'v5.10.0' )
If you may be running on a perl earlier than 5.6.0, you'll need to use $]
which returns a simple integer.