in reply to checking reference equality

The behavior you are using is discussed in Using References.
Using a reference as a number produces an integer representing its storage location in memory. The only useful thing to be done with this is to compare two references numerically to see whether they refer to the same location.

My Perl Fu is not so great as to let me weigh in on whether this is the "best" method.

Replies are listed 'Best First'.
Re^2: checking reference equality (ESP)
by tye (Sage) on May 11, 2009 at 07:03 UTC
    The only useful thing to be done with this is to compare two references numerically to see whether they refer to the same location.

    I guess this means that the author of that doesn't consider Acme::ESP to be useful. I'm not sure if I should feel hurt... ;)

    - tye        

Re^2: checking reference equality
by perl5ever (Pilgrim) on May 11, 2009 at 01:14 UTC
    Thanks for pointing that out. I was only checking perldoc perlop.
Re^2: checking reference equality
by John M. Dlugosz (Monsignor) on May 12, 2009 at 15:18 UTC
    Re: My Perl Fu is not so great as to let me weigh in on whether this is the "best" method. The document cited shows == to numerically compare addresses to see if two references point to the same object.

    It does not consider overloading == by the class so referenced. For example, I'm sure BigNum will give you equality of the referenced values, not co-referencing.

    So, this is true only for unblessed items. For objects, == should be assumed to be some kind of equivilance operation as befitting the class. So, for Best Practices, I would not use it for object identity.

    That core man page doesn't list any maintainer to email with corrections. Perhaps someone involved will see this and mention it on the proper list.

    For completeness, let me point out that Perl 6 has a === operator for this express purpose.