my $x; # unless overloaded, numeric values of two refs to the same thing are equal {package X; use Carp; sub is_x { carp \$x == \$_[0] ? "ok" : "not ok" }} X::is_x($x); X::is_x(++$x); X::is_x($x++); X::is_x($x+0);