sub UNIVERSAL::native_can { my ($obj,$meth) = @_; $obj = ref($obj) || $obj; local @{"${obj}::ISA"}; return $obj->can($meth); } my $obj = Class::Child->new; # Class::Child inherits 'foo' from Class::Parent print $obj->can('foo') ? 1 : 0; # 1 print $obj->native_can('foo') ? 1 : 0; # 0
In reply to Re: A function to check if subroutine exists?
by japhy
in thread A function to check if subroutine exists?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |