autobox 

use autobox;

if( $thing->can('id') ) {
    say "Object ID is ", $thing->id;
}
else {
    say "Object has no unique ID";
}