g0n has asked for the wisdom of the Perl Monks concerning the following question:
I've written a custom module to automate deployment of some fairly complex config. My boss opined that it would be nice if the auto deployment was contained in a single file rather than a separate script and module. So I take my DataMethods.pm file and >> it onto the end of 'install.pl', then remove the 'use DataMethods' from the script part to see what happens. What happens is that everything works fine apart from inheritance. For example:
##############inheritest.pl####################### #use mammal; my $object = mammal::badger->new; print $object->hunt; print $object->snuffle; ############################################## package mammal; use vars qw(@ISA); sub new { my %object = ('blood'=>'warm'); return bless \%object; } sub snuffle { return "Snuffle"; } package mammal::badger; use vars qw(@ISA); @ISA = qw (mammal); sub new { my %object = ('stripes'=>'true'); return bless \%object; } sub hunt { return "for worms"; } 1;
This simple example script complains that method 'snuffle' doesn't exist, but runs method 'hunt' successfully.
I know this isn't exactly a normal approach to writing OO perl, but the effect is interesting. Anyone care to comment/set me right?
Perl version is 5.005_51 BTW
charles.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: object inheritance in non ~.pm files
by Mutant (Priest) on Jan 27, 2005 at 13:59 UTC | |
by g0n (Priest) on Jan 27, 2005 at 14:16 UTC | |
|
Re: object inheritance in non ~.pm files
by dragonchild (Archbishop) on Jan 27, 2005 at 13:51 UTC | |
by PodMaster (Abbot) on Jan 27, 2005 at 13:56 UTC | |
|
Re: object inheritance in non ~.pm files
by Tanktalus (Canon) on Jan 27, 2005 at 14:26 UTC | |
|
Re: object inheritance in non ~.pm files
by ikegami (Patriarch) on Jan 27, 2005 at 15:32 UTC |