if (definde $thing and ref($thing) and $thing->can('do_something')) { $thing->do_something }