Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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

Replies are listed 'Best First'.
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 choroba (Chancellor) on Aug 02, 2013 at 07:17 UTC
    Importing (require) does not establish inheritance.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
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?
[erix]: Alvin Lee (Ten Years After) played a jazzguitar ("Big Red"), a good warm sound
[stonecolddevin]: I think Stevie Ray is one of maybe 2 or 3 people that could take a Hendrix song and make you go "...huh. this is close." https://open. spotify.com/track/ 0UVM9trirBK5s1xBwL oVhZ
[stonecolddevin]: https://open. spotify.com/track/ 0UVM9trirBK5s1xBwL oVhZ rather
[Corion]: Sadly I must go to bed now :-| See y'all!
[erix]: I really loved/love this "Recorded Live" record, 1973 (yes, I'm that old)
[stonecolddevin]: goodnight Corion
[erix]: cya Corion :)
[stevieb]: Joan Jett, Hendrix, Neil Young, Dave Keuning (The Killers)... I have my mind elsewhere so I'm limited in my capacity to think about this righ tnow ;)
[erix]: another blues with Big Red :)
[stonecolddevin]: I will say John Mayer is an excellent guitarist, I don't like his music but he's pretty damn good

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2017-06-22 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.