#! /usr/bin/perl use strict; use warnings; use Scalar::Util qw(refaddr); sub same { ref($_[0]) && ref($_[1]) && refaddr($_[0]) == refaddr($_[1]) || refaddr(\$_[0]) == refaddr(\$_[1]); }; use Test::More 'no_plan'; our ($x, $y, $z) = (1,1); *z = *x; ok same($x, $x), 'x is x'; ok same(\$x, \$x), 'ref x is ref x'; ok !same($x, $y), 'x not y'; ok same($x, $z), 'x is z';