I think that's an interesting idea, but I can see where it might not work when you expect it to. Much like UNIVERSAL::isa, some people may call UNIVERSAL::can directly as a static method so as to avoid having to check if something is an object or package name. Contrived example:
sub has_method { my ( $target, $method ) = @_; return UNIVERSAL::can( $target, $method) ? 1 : 0; }
How often this will occur is hard to say, but it's at least worth a warning in the documentation. Whether it's advisable is entirely another issue -- I generally tend to think that one should realize that modules might override UNIVERSAL functions for a reason and respect that.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re: Fixing nits with $object->can($method);
by xdg
in thread Fixing nits with $object->can($method);
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |