in reply to Re: Comparing references to sub's
in thread Comparing references to sub's

Comparing references is a stable and well-defined operation:
if ( $thisref eq $thatref ) { # these are two refs address the same object, whatever it is }
(update: as diotalevi has pointed out, the "==" comparison would be more efficient that the "eq", but otherwise the results are equivalent.)

Replies are listed 'Best First'.
Re^3: Comparing references to sub's
by adrianh (Chancellor) on Mar 20, 2003 at 08:49 UTC

    If you want to be really sure you should use refaddr from Scalar::Util since the reference type could overload any of eq, ==, "" or 0+.

    Obviously not necessary in this case, but not doing it can catch you out (well, it's caught me out before) if you add overloading at a later date.