Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Why version strings?

by Corion (Patriarch)
on Mar 28, 2011 at 14:43 UTC ( [id://895933]=note: print w/replies, xml ) Need Help??


in reply to Why version strings?

Specifying the minimum version of Perl needed for your script in your script is like specifying what fuel your car runs on - it allows Perl to exit with a more sensible error message than Syntax error ... when a lower version of Perl is run with your script.

How would a version 5.10 Perl know about new syntactic features introduced in 5.14?

Replies are listed 'Best First'.
Re^2: Why version strings?
by gunzip (Pilgrim) on Mar 28, 2011 at 15:04 UTC
    How would a version 5.10 Perl know about new syntactic features introduced in 5.14?

    Isn't that rather a case for improving error messages, not imposing a requirement on every single script?

      How would you improve the error messages for Perl 5.6, a version that was last released in 2002 (or something), today?

Re^2: Why version strings?
by gunzip (Pilgrim) on Mar 28, 2011 at 14:59 UTC
    I'd rather work out the "Syntax error .." than have to enter the version string in every single piece of Perl that I write. We didn't need it with 5.8 so why now?
      I'd rather work out the "Syntax error .." than have to enter the version string in every single piece of Perl that I write.

      That's your choice. I for one write quite a lot Perl 6 scripts, and thus often actually mix up the versions of the compiler and the language. To me it's incredibly helpful.

      We didn't need it with 5.8 so why now?

      You don't need to. It works fine without.

      It won't give you some new built-in though, because that would break backwards compatiblity with older scripts.

      In general it is a good idea to declare a version, in particular in the light of the faster Perl 5 development process. But of course it's still your choice.

      Don't you have a standard-header you copy to each of your scripts? With use strict, , use warnings; and a copyright-notice? Adding one additonal line specifying the perl-version is no big deal - and nothing to get emotional about ;-)

      All the best, Rata

      It's not all about working out the syntax error, either (even if "you need a newer version of perl" seems much better than some "yada-error in Foo::Bar line 1234").

      With the version string, automated tools can decide which is the newest version of the module they can use on a given installation. One of these tools is cpantesters. For example my Maplat project uses some features of perl 5.12, so it wont work on older perl installations:

      Maplat CPAN Testers results

      The "Pass summary" table gives the potential user a good overview which Maplat version works on which OS and perl version.

      The detail tables gives me as a developer a good overview where the bugs are. It differenciates between NA (not available), PASS and FAIL. This makes it much easier to use my limited time to hunt for real, *new* bugs than having to sort out known incompatibilities.

      Also, if i ever want to backport some modules to older versions of perl (for whatever reasons), i can simply grep through the files for the version string and find the one that are too modern. Works the other way around, too, when a newer version of perl changes/fixes/removes some "experimental" features of the previous version.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://895933]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-19 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found