if ( ref( $obj ) eq 'Foo::Bar' ) { # This is generally wrong } use Scalar::Util 'blessed'; if ( blessed( $obj ) and $obj->can( $some_method ) ) { # We asked if the object could do something. We win. OO inheritance was respected and we played by the rules. } if ( blessed( $obj ) and $obj->isa( 'Some::Object' ) ) { # This is close to your original and is slightly deprecated but also respects OO inheritance. }