in reply to Re^3: Am I evil for doing this?
in thread Am I evil for doing this?
It's so much less evil, in fact, that it's actually allowed by strict.Yes; but there is considerable disagreement as to whether this ought to be the case. Some very respectable occupants of the Perl pantheon believe that it's an unnecessary and arbitrary loophole.
If you wanted to be extra careful, you could use UNIVERSAL::can...
That actually depends on what you want. If you want to allow the possibility that the method could get handled by AUTOLOAD, then you should not pre-test with UNIVERSAL::can.
There's also an issue with how you call can. I figure, if you don't know whether the object can handle the $method, then you might not know if it's even an object; so to avoid the error potentially resulting when $self is not an object, I usually do the following, though unfortunately it isn't as pretty:
if ( UNIVERSAL::can( $self, $method ) ) {
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Am I evil for doing this?
by ihb (Deacon) on Mar 11, 2005 at 12:39 UTC | |
by jdporter (Paladin) on Mar 11, 2005 at 14:24 UTC |