in reply to How to change referent of lexical reference?

I would be inclined to just define my own comparison method that made it obvious that I was doing a deep comparison that the two hashes had the same contents.

If you insist on being able to use == for this, you could try turning $foo into an overloaded object whose == method checked that both sides freeze into the same string (with $Storable::Canonical set to a true value of course, and modulo what you need to do for the overload to operate).

  • Comment on Re: How to change referent of lexical reference?

Replies are listed 'Best First'.
Re: Re: How to change referent of lexical reference?
by autarch (Hermit) on Sep 22, 2003 at 03:27 UTC
    See above. This isn't a question of comparison, but rather that I really don't want two objects that have the same data.
      The general part of the question (how to recognize other data structures that mirror data) is hard.

      But causing one reference to a data structure to be the same as another is fairly easy:

      sub some_sub { $_[0] = $bar; }
      The trick is that while variables are in @_ they are passed in by reference. If you don't make copies, then you can modify the passed in values. This API may surprise...
        As I mentioned in response to someone else, it doesn't work in this particular case, because of the way Storable calls the STORABLE_thaw() method.