Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Can't locate object method- Issue

by perl_noobie (Initiate)
on Aug 02, 2013 at 07:06 UTC ( #1047560=note: print w/ replies, xml ) Need Help??


in reply to Re: Can't locate object method- Issue
in thread Can't locate object method- Issue

Employee is already a subclass of Person (by virtue of use base ("Person") in Employee module), and the actual subclass of Person( Adult or Baby) is imported via dynamic check condition. Can you pls point out in the code what changes is to be made?


Comment on Re^2: Can't locate object method- Issue
Re^3: Can't locate object method- Issue
by choroba (Abbot) on Aug 02, 2013 at 07:17 UTC
    Importing (require) does not establish inheritance.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^3: Can't locate object method- Issue
by Corion (Pope) on Aug 02, 2013 at 07:18 UTC

    You want to use

    use Exporter 'import';

    ... if you really want to export methods into other parts of base classes.

    Honestly, I do not think that mixing multiple inheritance, reblessing and exporting of subroutines in the way you are doing it will lead to a sane object/class structure. Maybe you can tell us more about the problem you are trying to solve with this conoction?

Re^3: Can't locate object method- Issue
by Loops (Curate) on Aug 02, 2013 at 07:23 UTC
    On top of everything said by those more experienced monks above, you need to be careful when blessing an object that it actually matches one of your package names...
    bless($self, "Adult"); should be... bless($self, "Person::Adult");
    or even simple code that is not relying on your dynamic typing will fail:
    my $a = Person::Adult->new(NAME => 'the hard way'); $a->sayHi();

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047560]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2014-11-27 18:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (187 votes), past polls