.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Perl::MinimumVersion 3" .TH Perl::MinimumVersion 3 2024-09-01 "perl v5.40.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Perl::MinimumVersion \- Find a minimum required version of perl for Perl code .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 4 \& # Create the version checking object \& $object = Perl::MinimumVersion\->new( $filename ); \& $object = Perl::MinimumVersion\->new( \e$source ); \& $object = Perl::MinimumVersion\->new( $ppi_document ); \& \& # Find the minimum version \& $version = $object\->minimum_version; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\f(CW\*(C`Perl::MinimumVersion\*(C'\fR 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. .PP Currently it tests both the syntax of your code, and the use of explicit version dependencies such as \f(CW\*(C`require 5.005\*(C'\fR. .PP Future plans are to also add support for tracing module dependencies. .PP Using \f(CW\*(C`Perl::MinimumVersion\*(C'\fR is dead simple, the synopsis pretty much covers it. .PP The distribution comes with a script called perlver, which is the easiest way to run \f(CW\*(C`Perl::MinimumVersion\*(C'\fR on your code: .PP .Vb 1 \& % perlver lib/Foo/Bar.pm .Ve .PP See the documentation for perlver for more details. .SH METHODS .IX Header "METHODS" .SS new .IX Subsection "new" .Vb 4 \& # Create the version checking object \& $object = Perl::MinimumVersion\->new( $filename ); \& $object = Perl::MinimumVersion\->new( \e$source ); \& $object = Perl::MinimumVersion\->new( $ppi_document ); .Ve .PP The \f(CW\*(C`new\*(C'\fR 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 \f(CW\*(C`SCALAR\*(C'\fR reference containing the code. .PP Returns a new \f(CW\*(C`Perl::MinimumVersion\*(C'\fR object, or \f(CW\*(C`undef\*(C'\fR on error. .SS Document .IX Subsection "Document" The \f(CW\*(C`Document\*(C'\fR accessor can be used to get the PPI::Document object back out of the version checker. .SS minimum_version .IX Subsection "minimum_version" The \f(CW\*(C`minimum_version\*(C'\fR method is the primary method for finding the minimum perl version required based on \f(CW\*(C`all\*(C'\fR factors in the document. .PP At the present time, this is just syntax and explicit version checks, as Perl::Depends is not yet completed. .PP Returns a version object, or \f(CW\*(C`undef\*(C'\fR on error. .SS minimum_explicit_version .IX Subsection "minimum_explicit_version" The \f(CW\*(C`minimum_explicit_version\*(C'\fR method checks through Perl code for the use of explicit version dependencies such as. .PP .Vb 2 \& use 5.006; \& require 5.005_03; .Ve .PP Although there is almost always only one of these in a file, if more than one are found, the highest version dependency will be returned. .PP Returns a version object, false if no dependencies could be found, or \f(CW\*(C`undef\*(C'\fR on error. .ie n .SS "minimum_syntax_version $limit" .el .SS "minimum_syntax_version \f(CW$limit\fP" .IX Subsection "minimum_syntax_version $limit" The \f(CW\*(C`minimum_syntax_version\*(C'\fR method will explicitly test only the Document's syntax to determine it's minimum version, to the extent that this is possible. .PP It takes an optional parameter of a version object defining the lowest known current value. For example, if it is already known that it must be 5.006 or higher, then you can provide a param of qv(5.006) and the method will not run any of the tests below this version. This should provide dramatic speed improvements for large and/or complex documents. .PP The limitations of parsing Perl mean that this method may provide artificially low results, but should not artificially high results. .PP For example, if \f(CW\*(C`minimum_syntax_version\*(C'\fR returned 5.006, you can be confident it will not run on anything lower, although there is a chance that during actual execution it may use some untestable feature that creates a dependency on a higher version. .PP Returns a version object, false if no dependencies could be found, or \f(CW\*(C`undef\*(C'\fR on error. .SS minimum_external_version .IX Subsection "minimum_external_version" \&\fBWARNING: This method has not been implemented. Any attempted use will throw an exception\fR .PP The \f(CW\*(C`minimum_external_version\*(C'\fR examines code for dependencies on other external files, and recursively traverses the dependency tree applying the same tests to those files as it does to the original. .PP Returns a \f(CW\*(C`version\*(C'\fR object, false if no dependencies could be found, or \&\f(CW\*(C`undef\*(C'\fR on error. .SS version_markers .IX Subsection "version_markers" This method returns a list of pairs in the form: .PP .Vb 1 \& ($version, \e@markers) .Ve .PP Each pair represents all the markers that could be found indicating that the version was the minimum needed version. \f(CW@markers\fR is an array of strings. Currently, these strings are not as clear as they might be, but this may be changed in the future. In other words: don't rely on them as specific identifiers. .SH BUGS .IX Header "BUGS" \&\fBPerl::MinimumVersion\fR does a reasonable job of catching the best-known explicit version dependencies. .PP \&\fBHowever\fR 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. .PP I don't even need an entire diff... just the function and version. .SH "TO DO" .IX Header "TO DO" \&\fBWrite lots more version checkers\fR .PP \&\- Perl 5.10 operators and language structures .PP \&\- Three-argument open .PP \&\fBWrite the explicit version checker\fR .PP \&\fBWrite the recursive module descend stuff\fR .PP _while_readdir for postfix while without brackets .PP \&\fBCheck for more 5.12 features (currently only detecting \&\fR\f(CB\*(C`package NAME VERSION;\*(C'\fR\fB, \fR\f(CB\*(C`...\*(C'\fR\fB, and \fR\f(CB\*(C`use feature \*(Aq:5.12\*(Aq\*(C'\fR\fB)\fR .SH SUPPORT .IX Header "SUPPORT" All bugs should be filed via the CPAN bug tracker at .PP .PP For other issues, or commercial enhancement or support, contact the author. .SH AUTHORS .IX Header "AUTHORS" Adam Kennedy .SH "SEE ALSO" .IX Header "SEE ALSO" perlver \- the command-line script for running \f(CW\*(C`Perl::MinimumVersion\*(C'\fR on your code. .PP Perl::MinimumVersion::Fast \- another module which does the same thing. It's a lot faster, but only supports Perl 5.8.1+. .PP , PPI, version .SH REPOSITORY .IX Header "REPOSITORY" .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright 2005 \- 2014 Adam Kennedy. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP The full text of the license can be found in the LICENSE file included with this module.