in reply to Re^4: Am I evil for doing this?
in thread Am I evil for doing this?
if ( UNIVERSAL::can( $self, $method ) ) {
That too, unfortunately, isn't good either, if an autoloading class properly overloads can. Imho, a class that uses AUTOLOAD also has the obligation to overload can accordingly. If it doesn't that class should be fixed, not mine, if that's an option.
I prefer to do can checks like
if I need to handle $self's that can't invoke methods.if (blessed($self) || ! ref($self) and my $code = $self->can($method)) + { $self->$code(...); }
Update: Forgot to mention &blessed comes from Scalar::Util.
ihb
See perltoc if you don't know which perldoc to read!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Am I evil for doing this?
by jdporter (Paladin) on Mar 11, 2005 at 14:24 UTC |