VERSION in UNIVERSAL alternative?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I currently use an eval to obtain VERSION of the parent class [1]. I noted
that UNIVERSAL has VERSION, however,

states that " import ... and VERSION ), however it is usually harmful to
do so. Please don't do this in new code.

So, what's the alternative / better solution (and why isn't this in the
documentation ;-) ).

[1] my $package = ref $self;
    my $version = eval "$$::VERSION";

John Bokma                                                               j3b

Hacking & Hiking in Mexico - - Perl & Python Development

Re: VERSION in UNIVERSAL alternative?

Quoted text here. Click to load it

UNIVERSAL has a version *method*. It's a bad idea to call any of
UNIVERSAL's methods as *functions*, since that prevents classes from
overriding them.

Quoted text here. Click to load it

    my $version = eval { $package->VERSION };


Site Timeline