Ovid has asked for the wisdom of the Perl Monks concerning the following question:
I wanted to check to see if the method I was writing was overriding an existing method in a parent class. That's when I realized that I don't know a truly clean way of doing that. I tried this, but it fails (as it should):
#!/usr/bin/perl -l use strict; use warnings; { package A; sub foo { 'Whee!' } sub check { return shift->SUPER::can('foo') } } print A->check->();
The only thing I can cleanly think of is walking through @ISA, but this seems like such an obvious thing that someone would have solved this.
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Detecting Overridden Methods
by ikegami (Patriarch) on Feb 05, 2007 at 16:24 UTC | |
by ikegami (Patriarch) on Feb 05, 2007 at 21:49 UTC | |
by Anonymous Monk on Feb 08, 2007 at 23:58 UTC | |
|
Re: Detecting Overridden Methods
by diotalevi (Canon) on Feb 05, 2007 at 16:28 UTC | |
|
Re: Detecting Overridden Methods
by Rhandom (Curate) on Feb 05, 2007 at 18:43 UTC | |
by Rhandom (Curate) on Feb 05, 2007 at 18:47 UTC | |
|
Re: Detecting Overridden Methods
by sfink (Deacon) on Feb 05, 2007 at 19:31 UTC | |
by ikegami (Patriarch) on Feb 05, 2007 at 19:38 UTC |