til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Find out what your Perl minimum version requirement is

This can be done quite easily using the magnificent tool: Perl::MinimumVersion by Neil Bowers.

The distribution includes the CLI tool perlver.

You can use it on a single file:

± perlver lib/Test/Timer.pm

   ------------------------------------------------
 | file              | explicit | syntax | external |
 | ------------------------------------------------ |
 | lib/Test/Timer.pm | ~        | v5.6.0 | n/a      |
 | ------------------------------------------------ |
 | Minimum explicit version : ~                     |
 | Minimum syntax version   : v5.6.0                |
 | Minimum version of perl  : v5.6.0                |
   ------------------------------------------------

Or you can use it on a directory, your distribution for example. Do note that this is not as fast as it is useful.

$ perlver .

   -----------------------------------------------------------------
 | file                               | explicit | syntax | external |
 | ----------------------------------------------------------------- |
 | t/test-tester.t                    | ~        | v5.6.0 | n/a      |
 | t/time_alert.t                     | ~        | v5.6.0 | n/a      |
 | t/_benchmark.t                     | ~        | v5.5.3 | n/a      |
 | t/Test/Timer/Test.pm               | ~        | v5.6.0 | n/a      |
 | prototypes/benchmark.pl            | ~        | v5.6.0 | n/a      |
 | prototypes/time_ok.pl              | ~        | v5.6.0 | n/a      |
 | prototypes/time_between.pl         | ~        | v5.6.0 | n/a      |
 | prototypes/time_atleast.pl         | ~        | v5.6.0 | n/a      |
 | prototypes/time_atmost.pl          | ~        | v5.6.0 | n/a      |
 | prototypes/list_context.pl         | ~        | v5.6.0 | n/a      |
 | prototypes/time_nok.pl             | ~        | v5.6.0 | n/a      |
 | prototypes/regex.pl                | ~        | v5.6.0 | n/a      |
 | lib/Test/Timer.pm                  | ~        | v5.6.0 | n/a      |
 | lib/Test/Timer/TimeoutException.pm | ~        | v5.6.0 | n/a      |
 | ----------------------------------------------------------------- |
 | Minimum explicit version : ~                                      |
 | Minimum syntax version   : v5.6.0                                 |
 | Minimum version of perl  : v5.6.0                                 |
   -----------------------------------------------------------------

And as you can read the minimum is provided to you.

If you want to find out as to why a certain version is required you can use the --explain flag.

$ perlver --blame lib/Test/Timer.pm

 ------------------------------------------------------------
 File    : lib/Test/Timer.pm
 Line    : 3
 Char    : 1
 Rule    : _perl_5006_pragmas
 Version : 5.006
 ------------------------------------------------------------
 use warnings;
 ------------------------------------------------------------

Remember to specify in your minimum requirements in your distribution requirements or similar afterwards.

Resources and References