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.
In reply to object inheritance in non ~.pm files by g0n
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |