Use the latest version of Perl to write scripts for the older version
When I place use v5.8;
at the beginning of my script, it means the script won't work unless it is interpreted by Perl 5.8 or higher. My question is, is there a way to make Perl work in compatibility mode for a specific version? So if I use a (dummy) string, for example use only::v5.8;
, my script won't work if it uses language features not present in Perl 5.8.
My use case is that I would like to be able to develop scripts for my work machine (which has an older version of Perl) using my personal laptop with a later one.
source to share
There is Perl :: MinimumVersion and Perl :: MinimumVersion :: Fast on CPAN.
There is also a command line tool for the former .
With these modules you can check if your program needs a newer version of perl. Unfortunately, there is little formatting.
perlver yourfile.pl
-----------------------------------------
| file | explicit | syntax | external |
| ----------------------------------------- |
| logfile.pl | v5.10.0 | v5.6.0 | n/a |
| ----------------------------------------- |
| Minimum explicit version : v5.10.0 |
| Minimum syntax version : v5.6.0 |
| Minimum version of perl : v5.10.0 |
-----------------------------------------
source to share