On Thu, 9 Dec 2004, Arshavir Grigorian wrote:

- my $atroot = ($root eq $self);
+ my $atroot = ((ref ($root) eq ref ($self)) && ($root eq $self));

Even better would be something like this:

 use Scalar::Util qw(refaddr);

 my $atroot = ref $root && refaddr($root) == refaddr($self);

By "overload aware", I mean that naively using "eq" to compare objects is not a good idea if you don't know the class of the objects, because you never know what might overload "eq".


-dave

/*===========================
VegGuide.Org
Your guide to all that's veg.
===========================*/

Reply via email to