in reply to Marking an array as already seen

Try this on for size ;)
sub foy { my $ref = shift; canonicalize($ref) unless $ref->isa('_Canonical'); }
update: I guess I should've read the entire thing first ;) but not to fear, read on ...

If I store a flag in a hash indexed by the ref's string, is that string always the same?

Yes. A reference to the same structure will always stringify the same (in the same instance of the program of course), otherwise, the perl garbage collector couldn't work (reference counting is, well, reference counting, so it has to stringify the same).

Also, to learn about attributes, check out the pragma.


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: Marking an array as already seen
by adrianh (Chancellor) on Jan 17, 2003 at 12:02 UTC
    Yes. A reference to the same structure will always stringify the same (in the same instance of the program of course), otherwise, the perl garbage collector couldn't work (reference counting is, well, reference counting, so it has to stringify the same).

    Unless, of course, it's a reference to a class that has overloaded ""... in which case you'll have to use refaddr from Scalar::Util :-)