use Scalar::Util qw(refaddr); if (refaddr($obj1) == refaddr($obj2)){ ... }