Perl Monk, Perl Meditation | |
PerlMonks |
Re^3: Question about __PACKAGE__by ikegami (Patriarch) |
on Jan 22, 2010 at 07:20 UTC ( [id://818906]=note: print w/replies, xml ) | Need Help?? |
I think you understand, but your wording leaves to be desired. The same sub is called in both cases; the difference is in how it's called: Foo->hello & hello are basically the same except the former is calling hello as a class method and passing 'Foo' (or whatever's left of the arrow) as the first arg, but the latter is calling hello as a subroutine and will not pass 'Foo'. One difference that wasn't mentioned is that inheritance will come into play when hello is called as a method.
And maybe even create subs, yes.
In Section
Seekers of Perl Wisdom
|
|