So, you have a module called Foo::Bar and objects of the class Foo::Bar, and you want to find the version of the module associated with the object, yes ? For example, while doing some superclass stuff ?
Which would be something along the lines:
and somewhere you have:package Foo::Bar ; ..... our $VERSION = "0.00" ; .....
and somewhere else you want to find the $VERSION associated with $obj ?my $obj = new Foo::Bar (...) ;
Suppose you had Foo/Bar.pm:
and Foo.pm:package Foo::Bar ; use strict ; use warnings ; our $VERSION = "1.01" ; use base qw(Foo); sub new { return bless [], shift ; } ; 1 ;
Then:package Foo ; use strict ; use warnings ; our $VERSION = "0.11" ; sub version { my ($self) = @_ ; no strict 'refs' ; # NB: seatbelt off. return ${ref($self)."::VERSION"} ; # "Symbolic Reference" } ; 1 ;
should print:use strict ; use warnings ; use Foo::Bar ; my $obj = new Foo::Bar ; print $obj->version(), "\n" ;
which may have been what you had in mind.1.01
It may also be what kyle just recommended NOT to do ?
In reply to Re: Perl Inheritance & module variables
by gone2015
in thread Perl Inheritance & module variables
by diabelek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |