On Mon, 14 Jan 2002, Michael A Nachbaur wrote:

> > sub equals {
> >     my ($self, $obj) = @_;
> >
> >     return $self eq $obj;
> > }
>
> Correct me if I'm wrong someone, but it seems that this would only evaluate
> if the hashrefs are equal (which wouldn't happen unless you did
> $obj->equals($obj)).  How about this?
> sub equals {
>     my ($self, $obj) = @_;
>     foreach my $key ( keys(%$self) ) {
>         return FALSE unless ( defined($obj->{$key}) and $self->{$key} eq
> $obj->{$key} );
>     }
>    return TRUE;
> }
>

And even so only if your hash is nested one deep :)

But you might want to check it two objects were the same one after all ?

/J\

Reply via email to