my $obj = MyClass->new(); # what if it returns undef on error? if ($obj->can('top') # dies! #### # Instead of: if (UNIVERSAL::isa($obj, 'MyClass') # do this: if (blessed $obj && $obj->isa('MyClass')) # Instead of: if (UNIVERSAL::can($obj, 'top') && UNIVERSAL::can($obj->top, 'bottom')) # do this: if (blessed $obj && $obj->can('top') && blessed $obj->top && $obj->top->can('bottom'))