http://qs321.pair.com?node_id=781620


in reply to What is the best way to compare variables so that different types are non-equal?

In addition to all other suggestions, if you're walking through a fixed data structure and want to prevent going to the same node twice, it can be worthwhile to numify references to nodes. That is instead of trying to look at, say, $foo{$bar} and see if you've been there, look at 0 + \$foo{$bar} instead.

This tests whether the underlying scalar has been seen, and will not care if the value is, or looks like, one that you've seen before.

Replies are listed 'Best First'.
Re^2: What is the best way to compare variables so that different types are non-equal?
by LanX (Saint) on Jul 21, 2009 at 09:58 UTC
    Explicitly numifying references never came to my mind, only stringifying... That's a very valuable trick in some occasions...

    Just voting once is not enough! 8)

    Thank you!

    Cheers Rolf