Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Why version strings?

by JavaFan (Canon)
on Mar 28, 2011 at 16:13 UTC ( [id://895952]=note: print w/replies, xml ) Need Help??


in reply to Why version strings?

I may be missing something obvious but if I have Perl 5.12 installed why should I have to specify:
use 5.012;
You are missing that fact that you don't have to.

Can't Perl detect which version is installed or something?
No, Perl cannot, but perl can. The point is, use 5.012; appears in the Perl program, and when the perl binary runs, it checks whether its version is at least the version required by the program. If not, the program is terminated with an appropriate message.

Note that since 5.10, use 5.010; (or later, or using use 5.10.0) there's an implied use feature ':5.10'; (or whatever version number you used). And since 5.12, the use version will enable strict. No enabling of features or strict happen when using require.

Also note that use v5.10; == use 5.10.0; == 5.010;. But use 5.10; == use 5.100;. Which, IMO, is not very DWIM.

I don't know whether there's a (single-line) syntax that at compile time checks for 5.10, but which doesn't enable features.

Replies are listed 'Best First'.
Re^2: Why version strings?
by ikegami (Patriarch) on Mar 28, 2011 at 23:12 UTC

    Also note that use v5.10; == use 5.10.0; == 5.010;. But use 5.10; == use 5.100;. Which, IMO, is not very DWIM.

    An unfortunate side-effect of having two similar but very different numbering systems. At least the error message is useful.

    $ perl -e'use 5.10;' Perl v5.100.0 required (did you mean v5.10.0?)--this is only v5.12.2, +stopped at -e line 1. BEGIN failed--compilation aborted at -e line 1.

    I don't know whether there's a (single-line) syntax that at compile time checks for 5.10, but which doesn't enable features.

    $ perl -M5.014 -e1 Perl v5.14.0 required--this is only v5.12.2, stopped. BEGIN failed--compilation aborted.
      $ perl -M5.014 -e1 Perl v5.14.0 required--this is only v5.12.2, stopped. BEGIN failed--compilation aborted.
      I fail to understand how that answers my question:
      I don't know whether there's a (single-line) syntax that at compile time checks for 5.10, but which doesn't enable features.
      If I substitute 5.010 for 5.014, 5.10 features are enabled:
      $ perl -M5.010 -e 'say "foo"' foo
        You can use require for version checks, but a better solution is to put it in the installation script.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found