sub my_eq { # make sure we are comparing like to like my $xRef = ref($_[0]); return '' unless ($xRef eq ref($_[1])); # compare pure scalars and regex's using 'eq' # compare reference addresses for the rest return ($xRef and ($xRef ne 'Regexp')) ? (Scalar::Util::refaddr($_[0]) == Scalar::Util::refaddr($_[1])) : ($_[0] eq $_[1]); }