Perl::...ersion(3pm)
โจ NAME โจ
Perl::MinimumVersion โ bestie, this is the module that sniffs out the minimum version of perl your code actually needs to run ๐
๐ธ SYNOPSIS ๐ธ
# Create the version checking object
$object = Perl::MinimumVersion->new( $filename );
$object = Perl::MinimumVersion->new( \$source );
$object = Perl::MinimumVersion->new( $ppi_document );
# Find the minimum version
$version = $object->minimum_version;
๐ DESCRIPTION ๐
So Perl::MinimumVersion takes your Perl source code and does the math on the lowest possible version of perl that could actually run it. And the way it does this?? It's built on PPI, so it can figure all this out without ever loading your code. Iconic behaviour, honestly. No execution, no risk, just vibes and parsing โจ
Right now it checks two things: the syntax of your code, and any explicit version dependencies you've declared, like require 5.008. Both. Obsessed.
Future plans (not yet, don't get too excited) include support for tracing module dependencies too ๐ฎ
Using Perl::MinimumVersion is dead simple โ the synopsis basically already told you everything, periodt.
The distribution also ships with a script called perlver, which is genuinely the easiest way to run Perl::MinimumVersion on your code:
% perlver lib/Foo/Bar.pm
Check the docs for perlver for the deets ๐ซถ
๐ METHODS ๐
new
# Create the version checking object
$object = Perl::MinimumVersion->new( $filename );
$object = Perl::MinimumVersion->new( \$source );
$object = Perl::MinimumVersion->new( $ppi_document );
The new constructor makes you a brand new version checking object for a PPI::Document. You can also hand it the document as a file name, or as a SCALAR reference that holds the code ๐ซ
It returns a fresh Perl::MinimumVersion object โ or undef if something went wrong ๐ญ
Document
The Document accessor is your little grabby hands for getting the PPI::Document object back out of the version checker. Give it back, bestie ๐ซด
minimum_version
The minimum_version method is the primary method โ it finds the minimum perl version required based on all the factors in the document.
At the present time that's just syntax plus explicit version checks, since Perl::Depends isn't finished yet ๐ง
Returns a version object, or undef on error.
minimum_explicit_version
The minimum_explicit_version method digs through your Perl code looking for explicit version dependencies like:
use 5.006;
require 5.005_03;
There's almost always only one of these in a file, but if it finds more than one, it returns the highest version dependency. Biggest one wins, no cap.
Returns a version object, false if no dependencies could be found, or undef on error.
minimum_syntax_version $limit
The minimum_syntax_version method explicitly tests only the Document's syntax to work out its minimum version โ to the extent that that's even possible, anyway.
It takes an optional parameter: a version object defining the lowest known current value. So like, if you already know it's gotta be 5.006 or higher, you can pass in a param of qv(5.006) and the method will justโฆ not run any of the tests below that version. Skipping the pointless ones ๐จ This should give you dramatic speed improvements on large and/or complex documents. Slay.
Heads up bestie: the limits of parsing Perl mean this method might give you results that are artificially low, but it should never give you results that are artificially high.
For example, if minimum_syntax_version returned 5.006, you can be confident it won't run on anything lower โ though there's a chance that during actual execution it might use some untestable feature that creates a dependency on a higher version. Sneaky ๐ญ
Returns a version object, false if no dependencies could be found, or undef on error.
minimum_external_version
WARNING: This method has not been implemented. Any attempted use will throw an exception. Do not pass go, do not collect $200 ๐
The minimum_external_version method examines code for dependencies on other external files, and recursively traverses that dependency tree, applying the same tests to those files as it does to the original. That's the plan, anyway.
Returns a version object, false if no dependencies could be found, or undef on error.
version_markers
This method returns a list of pairs shaped like this:
($version, \@markers)
Each pair represents all the markers that could be found indicating that that version was the minimum needed version. @markers is an array of strings. Currently those strings are not as clear as they might be โ but that might change in the future. In other words: don't rely on them as specific identifiers, bestie, they are not it ๐ซ
๐ BUGS ๐
Perl::MinimumVersion does a reasonable job of catching the best-known explicit version dependencies. Respect.
However โ and this is kind of the fun part โ it is exceedingly easy to add a new syntax check. So if you find something it's missing, copy and paste one of the existing 5 line checking functions, modify it to find the thing you want, and report it to rt.cpan.org along with the version needed. Easy peasy โจ
I don't even need an entire diffโฆ just the function and version. That's it. That's the whole ask ๐
๐ฆ TO DO ๐ฆ
- Write lots more version checkers
- Perl 5.10 operators and language structures
- Three-argument open
- Write the explicit version checker
- Write the recursive module descend stuff
_while_readdirfor postfix while without brackets- Check for more 5.12 features (currently only detecting
package NAME VERSION;,..., anduse feature ':5.12')
๐ SUPPORT ๐
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 ๐ซถ
๐ AUTHORS ๐
Adam Kennedy <adamk@cpan.org>
โญ SEE ALSO โญ
perlverโ the command-line script for runningPerl::MinimumVersionon your code.Perl::MinimumVersion::Fastโ another module which does the same thing. It's a lot faster, but only supports Perl 5.8.1+.- <http://ali.as/>, PPI, version
๐ง REPOSITORY ๐ง
<https://github.com/neilbowers/Perl-MinimumVersion>
๐ COPYRIGHT ๐
Copyright 2005 - 2014 Adam Kennedy.
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.
okay that's the whole page!! this one shipped as perl v5.40.1, dated 2025-08-10, and it came to you via the User Contributed Perl Documentation โจ thanks for reading bestie, go run perlver on something and have the best day ๐๐
๐ฆ where this page comes from
- ubuntu resolute: libperl-minimumversion-perl 1.44-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libperl-minimumversion-perl 1.44-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms