in reply to Re^4: Problem with Inheriting a Super Class
in thread Problem with Inheriting a Super Class
This didn't work.
I find that difficult to believe.
With that said, if you must generate accessors by hand (and you're better off using Moose), something like this should work. Please note that you should do this outside of your constructor:
BEGIN { for my $datum (qw( name full_name root_oid plugin_oid full_oid )) { my $sub = sub { my $self = shift; $self->{$datum} = shift if @_; return $self->{$datum}; }; do { no strict 'refs'; *{ $datum } = sub }; } }
If you don't explicitly shift off the invocant within the method, you won't access instance data.
Improve your skills with Modern Perl: the free book.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Problem with Inheriting a Super Class
by PyrexKidd (Monk) on Sep 20, 2011 at 20:12 UTC | |
by chromatic (Archbishop) on Sep 20, 2011 at 21:43 UTC |