Perl::MinimumVersion - Find the minimum required Perl version for any code
# Create the checker object $object = Perl::MinimumVersion->new( $filename ); $object = Perl::MinimumVersion->new( \$source ); $object = Perl::MinimumVersion->new( $Document ); # Find the minimum version $version = $object->minimum_version;
Perl::MinimumVersion takes Perl source code and calculates the minimum version of perl required to be able to run it. Because it is based on PPI, it can do this without having to actually load the code.
Perl::MinimumVersion
This first release only tests based on the syntax of your code.
As this module develops, it will also be able to check explicitly specified versions via require 5.005;, and trace module dependencies as needed.
require 5.005;
Amoungst other things, we hope to be able to build a test that is able to tell when the version needed based on the code syntax is higher than the version you explicitly specified (and thus, is a package bug).
Using Perl::MinimumVersion is dead simple, the synopsis pretty much covers it.
The new constructor creates a new version checking object for a PPI::Document. You can also provide the document to be read as a file name, or as a SCALAR reference containing the code.
new
SCALAR
Returns a new Perl::MinimumVersion object, or undef on error.
undef
The Document accessor can be used to get the PPI::Document object back out of the version checker.
Document
The minimum_version method is the primary method for finding the minimum perl version required based on all factors in the document.
minimum_version
all
Future versions of this package are expected to also add the methods minimum_syntax_version, minimum_explicit_version and minimum_module_version to handle the three ways in which the version dependency can be added.
minimum_syntax_version
minimum_explicit_version
minimum_module_version
Returns a version object, or undef on error.
It's very early days, so this probably doesn't catch anywhere near enough syntax cases, and I personally don't know enough of them.
However it is exceedingly easy to add a new syntax check, so if you find something this is missing, copy and paste one of the existing 5 line checking functions, modify it to find what you want, and report it to rt.cpan.org, along with the version needed.
I don't even need an entire diff... just the function and version.
- Write lots more version checkers
- Write the explicit version checker
- Write the recursive module descend stuff
All bugs should be filed via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-MinimumVersion
For other issues, or commercial enhancement or support, contact the author.
Adam Kennedy (Maintainer), http://ali.as/, cpan@ali.as
PPI, version
Copyright (c) 2005 Adam Kennedy. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install Perl::MinimumVersion, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::MinimumVersion
CPAN shell
perl -MCPAN -e shell install Perl::MinimumVersion
For more information on module installation, please visit the detailed CPAN module installation guide.