sub func1 { my $var = $_[0]; if (! ref($var) || ! $var->can('do_something1')) { die "Cannot call do_something1 on passed Var ($var); } # But really this check is redundant # because perl will die with a similar error if you # don't check. The check is only useful if you # want to do something other than die. $var->do_something1(); }
In reply to Re: Typecasting a scalar to a module
by Rhandom
in thread Typecasting a scalar to a module
by thekestrel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |