dreamlax has asked for the wisdom of the Perl Monks concerning the following question:

Consider an input file with following enteries:
1 3 4 5 6
1 6 4 5 3
1 2 4
4 2 1
...
...
Each row is a set without duplicates.
THe file itself represents a set of rows.
I am currently using set::Scalar to represent each row.
And Set:: Scalar to represent the set of rows.
The problem is that it contains duplicates values of sets.
i.e. the entries of set look like this
(3,4,5), (3,4,5) ,(1,4,5),....
if (3,4,5) is added twice.
How can one force the set to contain unique elemens.
thanks
sandeep

Replies are listed 'Best First'.
Re: Creating a family of set of integers
by borisz (Canon) on Jul 04, 2004 at 23:25 UTC
    With the unique method. @rows holds the rows and $s holds all unique elements from the rows.
    #!/usr/bin/perl use Set::Scalar; my @rows; while(<DATA>){ my @q = split ' '; push @rows, Set::Scalar->new(@q); } my $s = Set::Scalar->new->unique(@rows); __DATA__ 1 3 4 5 6 1 6 4 5 3 1 2 4 4 2 1
    Boris
Re: Creating a family of set of integers
by dreamlax (Initiate) on Jul 06, 2004 at 01:50 UTC
    I ran your program on input provided:
    when i print $s-members() it outputs null value.