Or better yet:if ( ref($var) && $var->isa("Some::Package") ) { $var->someMethod(); }
Of course you don't have to capture the return of "can" but it can be convenient.my $sub; if ( ref($var) && ($sub = $var->can("someMethod")) ) { $sub->(); } else { die "Method someMethod not found." }
In reply to Re^2: How to tell if a variable is blessed ?
by linux454
in thread How to tell if a variable is blessed ?
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |