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

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

Replies are listed 'Best First'.
Re^6: Why eval $version?
by Haarg (Priest) on Jul 10, 2020 at 10:04 UTC

    Correct. use Module 1.2; is equivalent to:

    BEGIN {
        require Module;
        Module->VERSION(1.2);
        Module->import;
    }
    

    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 version.pm 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