1Perl::MinimumVersion(3)User Contributed Perl DocumentatioPnerl::MinimumVersion(3)
2
3
4
6 Perl::MinimumVersion - Find a minimum required version of perl for Perl
7 code
8
10 # Create the version checking object
11 $object = Perl::MinimumVersion->new( $filename );
12 $object = Perl::MinimumVersion->new( \$source );
13 $object = Perl::MinimumVersion->new( $ppi_document );
14
15 # Find the minimum version
16 $version = $object->minimum_version;
17
19 "Perl::MinimumVersion" takes Perl source code and calculates the
20 minimum version of perl required to be able to run it. Because it is
21 based on PPI, it can do this without having to actually load the code.
22
23 Currently it tests both the syntax of your code, and the use of
24 explicit version dependencies such as "require 5.005".
25
26 Future plans are to also add support for tracing module dependencies.
27
28 Using "Perl::MinimumVersion" is dead simple, the synopsis pretty much
29 covers it.
30
31 The distribution comes with a script called perlver, which is the
32 easiest way to run "Perl::MinimumVersion" on your code:
33
34 % perlver lib/Foo/Bar.pm
35
36 See the documentation for perlver for more details.
37
39 new
40 # Create the version checking object
41 $object = Perl::MinimumVersion->new( $filename );
42 $object = Perl::MinimumVersion->new( \$source );
43 $object = Perl::MinimumVersion->new( $ppi_document );
44
45 The "new" constructor creates a new version checking object for a
46 PPI::Document. You can also provide the document to be read as a file
47 name, or as a "SCALAR" reference containing the code.
48
49 Returns a new "Perl::MinimumVersion" object, or "undef" on error.
50
51 Document
52 The "Document" accessor can be used to get the PPI::Document object
53 back out of the version checker.
54
55 minimum_version
56 The "minimum_version" method is the primary method for finding the
57 minimum perl version required based on "all" factors in the document.
58
59 At the present time, this is just syntax and explicit version checks,
60 as Perl::Depends is not yet completed.
61
62 Returns a version object, or "undef" on error.
63
64 minimum_explicit_version
65 The "minimum_explicit_version" method checks through Perl code for the
66 use of explicit version dependencies such as.
67
68 use 5.006;
69 require 5.005_03;
70
71 Although there is almost always only one of these in a file, if more
72 than one are found, the highest version dependency will be returned.
73
74 Returns a version object, false if no dependencies could be found, or
75 "undef" on error.
76
77 minimum_syntax_version $limit
78 The "minimum_syntax_version" method will explicitly test only the
79 Document's syntax to determine it's minimum version, to the extent that
80 this is possible.
81
82 It takes an optional parameter of a version object defining the lowest
83 known current value. For example, if it is already known that it must
84 be 5.006 or higher, then you can provide a param of qv(5.006) and the
85 method will not run any of the tests below this version. This should
86 provide dramatic speed improvements for large and/or complex documents.
87
88 The limitations of parsing Perl mean that this method may provide
89 artificially low results, but should not artificially high results.
90
91 For example, if "minimum_syntax_version" returned 5.006, you can be
92 confident it will not run on anything lower, although there is a chance
93 that during actual execution it may use some untestable feature that
94 creates a dependency on a higher version.
95
96 Returns a version object, false if no dependencies could be found, or
97 "undef" on error.
98
99 minimum_external_version
100 WARNING: This method has not been implemented. Any attempted use will
101 throw an exception
102
103 The "minimum_external_version" examines code for dependencies on other
104 external files, and recursively traverses the dependency tree applying
105 the same tests to those files as it does to the original.
106
107 Returns a "version" object, false if no dependencies could be found, or
108 "undef" on error.
109
110 version_markers
111 This method returns a list of pairs in the form:
112
113 ($version, \@markers)
114
115 Each pair represents all the markers that could be found indicating
116 that the version was the minimum needed version. @markers is an array
117 of strings. Currently, these strings are not as clear as they might
118 be, but this may be changed in the future. In other words: don't rely
119 on them as specific identifiers.
120
122 Perl::MinimumVersion does a reasonable job of catching the best-known
123 explicit version dependencies.
124
125 However it is exceedingly easy to add a new syntax check, so if you
126 find something this is missing, copy and paste one of the existing 5
127 line checking functions, modify it to find what you want, and report it
128 to rt.cpan.org, along with the version needed.
129
130 I don't even need an entire diff... just the function and version.
131
133 Write lots more version checkers
134
135 - Perl 5.10 operators and language structures
136
137 - Three-argument open
138
139 Write the explicit version checker
140
141 Write the recursive module descend stuff
142
143 _while_readdir for postfix while without brackets
144
145 Check for more 5.12 features (currently only detecting "package NAME
146 VERSION;", "...", and "use feature ':5.12'")
147
149 All bugs should be filed via the CPAN bug tracker at
150
151 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-MinimumVersion>
152
153 For other issues, or commercial enhancement or support, contact the
154 author.
155
157 Adam Kennedy <adamk@cpan.org>
158
160 perlver - the command-line script for running "Perl::MinimumVersion" on
161 your code.
162
163 Perl::MinimumVersion::Fast - another module which does the same thing.
164 It's a lot faster, but only supports Perl 5.8.1+.
165
166 <http://ali.as/>, PPI, version
167
169 <https://github.com/neilbowers/Perl-MinimumVersion>
170
172 Copyright 2005 - 2014 Adam Kennedy.
173
174 This program is free software; you can redistribute it and/or modify it
175 under the same terms as Perl itself.
176
177 The full text of the license can be found in the LICENSE file included
178 with this module.
179
180
181
182perl v5.32.1 2021-05-06 Perl::MinimumVersion(3)