AlphaWolf has asked for the wisdom of the Perl Monks concerning the following question:
given a package with a constructor, is there a way to autoload the object itself to return a given value/subroutine value? i tried something like this:
my goal is that if i $object = MyPackage->new(); then i can do print $objectpackage MyPackgage; sub new { my $this = shift; my $class = ref($this) || $this; my $self = {}; bless $self, $class; return $self; } sub AUTOLOAD { my $self = shift; return "ook?"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Anonymous Autoloading with OOP?
by ikegami (Patriarch) on Oct 12, 2008 at 19:37 UTC | |
|
Re: Anonymous Autoloading with OOP?
by Corion (Patriarch) on Oct 12, 2008 at 19:31 UTC |