Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Detecting Overridden Methods

by sfink (Deacon)
on Feb 05, 2007 at 19:31 UTC ( #598389=note: print w/replies, xml ) Need Help??


in reply to Detecting Overridden Methods

If you know the set of methods you'll need to query, you could check before any of your methods are installed.
package MyPackage; use base "Whatever"; our $can_foo; BEGIN { $can_foo = 1 if MyPackage->can("foo"); } sub foo { 'Whee!' } sub check { return $can_foo; }
Update: But in direct answer to your question, this (surprisingly) seems to work:
MyPackage->can("SUPER::foo")

Replies are listed 'Best First'.
Re^2: Detecting Overridden Methods
by ikegami (Pope) on Feb 05, 2007 at 19:38 UTC

    our $can_foo;
    is not as good as
    my $can_foo;
    There's no need for a package variable here.

    MyPackage->can("foo");
    is not as good as
    __PACKAGE__->can("foo");
    Less redundancy means smaller chance to make an error.

    I had written this solution before coming up with the one I posted. I couldn't see any advantages to it, so I only included it in my post in comment tags.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://598389]
help
Chatterbox?
[marto]: plastering
LanX citing Sean Connery
[LanX]: met a guy from Aberdeen durin holidays, liked Scotsish accent a lot ... very phonetic
[LanX]: ... understood everything after mentally write down what he said.
[choroba]: Trainspotting?

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2018-02-19 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (261 votes). Check out past polls.

    Notices?