Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^4: Why eval $version?

by Haarg (Curate)
on Jul 09, 2020 at 18:33 UTC ( #11119105=note: print w/replies, xml ) Need Help??

in reply to Re^3: Why eval $version?
in thread Why eval $version?

No, it works because on perl 5.10 and newer, version comparisons done by a use are performed using version (or an equivalent core routine) that accounts for the underscores, as well as multi-part versions (e.g. v1.2.3).

Replies are listed 'Best First'.
Re^5: Why eval $version?
by LanX (Sage) on Jul 09, 2020 at 20:49 UTC
    So use is compiling the module found in @INC first and checks the executed package var $VERSION then?

    Hence no a priori static parsing of the source ?

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Correct. use Module 1.2; is equivalent to:

      BEGIN {
          require Module;

      The ->VERSION method on perl 5.8 just uses a simple numeric comparison against $VERSION. On modern perls, it understands both numeric versions and multi-part versions, as well as underscores. The module can be loaded on perl 5.8 to allow it to understand these versions.

      "Static" parsing is done by the toolchain modules that are concerned with installing, updating, and indexing perl modules. These modules don't want to have to load the entire module to be able to compare versions. They also need to be able to work with modules that are not able to be loaded, such as not having their dependencies available or requiring an XS component that is not compiled yet. With a use call, you are already telling perl to load the file, so there's no need for the extra work involved in "static" parsing.

        so if all toolchain modules use version it should be also possible to use multi-part versions (like "v1.2.3_02") correct for Perl >5.10?

        Do they?

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2021-10-25 22:45 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.