in reply to Calling can method
Cheers,
Jeroen
"We are not alone"(FZ)
Update: Ahum... indeed. The perl OO is really confusing. But, now I remember again, UNIVERSAL::can('Test','foo') is actually the same as Test->can('foo'). Because in the last case, the word Test gets unshifted into @_, and the method 'can' is found in UNIVERSAL. So internally, actually UNIVERSAL::can is called, with the args ('Test', @_), which comes down to the same.
So this is actually a feature, not a bug {grin}
To clarify a bit more (mehopes):
You see? The Package::can only gives the route to the method (if not given, perl finds it from ISA). The -> only tells which thing to unshift in @_.package Test; package main; print "it works\n" if Test->UNIVERSAL::can('can'); print "it works\n" if Test->SUPER::can('can');
Of course, the sub need a way to filter out whether they are called with a Package or an object. So the trick doesn't work with all methods.
It's explained also in the 'Inheritance' section of perltoot.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Calling can method
by gildir (Pilgrim) on May 30, 2001 at 13:52 UTC | |
by merlyn (Sage) on May 30, 2001 at 17:01 UTC | |
by gildir (Pilgrim) on May 30, 2001 at 17:48 UTC | |
by merlyn (Sage) on May 30, 2001 at 17:58 UTC | |
by chromatic (Archbishop) on May 30, 2001 at 21:08 UTC | |
by chipmunk (Parson) on May 30, 2001 at 21:19 UTC | |
by tye (Sage) on May 30, 2001 at 22:25 UTC |