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_readdir for postfix while without brackets
  • Check for more 5.12 features (currently only detecting package NAME VERSION;, ..., and use 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 running Perl::MinimumVersion on 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 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