3

When I put use v5.8; at the top of my script, this means the script will not run unless it's being interpreted by Perl 5.8 or better. My question is, is there a way to force Perl to run in "compatibility mode" for a specific version? So that if I use a (fictitious) line like use only::v5.8;, my script will not run if it uses language features that weren't 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 Perl release) using my personal laptop which has a more recent one.

1
  • 6
    It would be far more reliable to simply install the older version on your work machine. perlbrew makes that easy. Commented Dec 17, 2014 at 4:23

1 Answer 1

4

There are Perl::MinimumVersion and Perl::MinimumVersion::Fast on CPAN.

For the former there is also a command line tool.

With those modules you can check if your program needs a more recent perl version. Sadly the formatting is a little of.

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                       |
   -----------------------------------------  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.