in reply to Re: Let's unite sets
in thread Let's unite sets

Would your union works for objects?
my @unique = union{ $_[0]->isSameNode } [ qw( list of xml nodes ) ], [ qw( other list of xml nodes ) ] #unique node list

Edited by castaway - added code tags

Replies are listed 'Best First'.
Re^3: Let's unite sets
by tlm (Prior) on Mar 28, 2005 at 22:04 UTC

    Certainly. Notice that the hash keys are "stringified objects", which include a memory locations, like this:

    % perl -le 'print bless +{}, "Foo"' Foo=HASH(0x814cbb8)
    So objects are considered equal only if their "stringifications" match. You still recover the original object from the corresponding hash value.

    the lowliest monk

Re^3: Let's unite sets
by jdporter (Paladin) on Mar 29, 2005 at 01:33 UTC
    It would, and does. I encourage you to try it for yourself. I also encourage you to look at existing modules, such as Set::Object, which generally do a lot more than just union.
      Ok it works for objects. Then how about reference object?
        I don't know what you're asking, since objects "are" references in perl. Why don't you try it yourself, on a test you think is meaningful. Then, if it doesn't work, show us what you did and what you expected to happen that didn't happen.