sub foo { ... $_[0] = $obj goto scalar $_[0]->can("method"); }