http://qs321.pair.com?node_id=1092256


in reply to Run-time equivalent of "use Module VERSION"?

VERSION is magic and always there for you:

> perl -wle "package VersionTest; use vars qw($VERSION); $VERSION=666; + package main; print VersionTest->VERSION(666); print VersionTest->VE +RSION(667);" 666 VersionTest verion 667 required--this is only version 666 at -e line 1 +.

Replies are listed 'Best First'.
Re^2: Run-time equivalent of "use Module VERSION"?
by LanX (Saint) on Jul 04, 2014 at 13:07 UTC
    > VERSION is magic and always there for you:

    elaborating a bit from perlobj#VERSION($need) :)

    UNIVERSAL::VERSION() is like ->can() a "universal"¹ method and ...

    This method is called automatically by the "VERSION" form of "use".
    use A 1.2 qw(some imported subs); # implies: A->VERSION(1.2);

    Cheers Rolf

    (addicted to the Perl Programming Language)

    ¹) All classes automatically inherit from the UNIVERSAL class, which is built-in to the Perl core.