Title: RE: Probably need help with a hash to do this

List::Compare does look like a neat way to do this. If you want to do code it yourself you could also use this fairly simple code.

use strict;

my @data = "">
'08|10|13|16|19|22|28|32|33|37|41|46|47|50|51|52|53|55|71|76', # row 1
'06|11|16|19|20|29|31|35|39|44|50|57|58|59|60|62|71|72|76|77', # row 2
'03|05|06|08|09|19|11|16|17|28|31|41|42|43|45|46|56|61|69|79', # row 3
'05|07|12|13|15|16|17|19|21|25|41|45|47|48|53|58|63|69|76|79', # etc...
'01|02|04|07|08|12|17|19|25|27|29|34|38|44|47|60|62|64|73|75',
'01|04|06|07|08|09|11|13|14|19|25|26|37|39|41|60|61|62|63|80',
'04|07|09|17|19|27|28|29|39|41|46|51|52|54|57|58|60|68|74|80'
);


my %firstset = map { $_ => 1 } split(/\|/,shift(@data));


foreach (@data)
{
        my %nextset = map { $_ => 1 } split(/\|/,$_);
       
        foreach my $num (keys %firstset)
        {
       
                if (! $nextset{$num})
                {
                        delete $firstset{$num};
                }

        }

}

### ALL THAT SHOULD BE LEFT IN %firstset IS UNIQUE ENTRIES

foreach my $num (keys %firstset)
{
        print "$num\n";
}


# END


-Pete

> -----Original Message-----
> From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 10, 2004 2:29 PM
> To: 'steve silvers'; [EMAIL PROTECTED]
> Subject: RE: Probably need help with a hash to do this
>
>
> My understanding of your problem is different from the other
> responders. I
> believe what you want is the "intersection" of each "row" of
> numbers. If
> this is correct, the following works:
>
> #!perl -w
> use strict;
> use List::Compare;
>
> my @data = "">
> '08|10|13|16|19|22|28|32|33|37|41|46|47|50|51|52|53|55|71|76|99',
> '06|11|16|19|20|29|31|35|39|44|50|57|58|59|60|62|71|72|76|77|99',
> '03|05|06|08|09|10|11|16|17|28|31|41|42|43|45|46|56|61|69|79|99',
> '05|07|12|13|15|16|17|19|21|25|41|45|47|48|53|58|63|69|76|79|99',
> '01|02|04|07|08|12|17|19|25|27|29|34|38|44|47|60|62|64|73|75|99',
> '01|04|06|07|08|09|11|13|14|19|25|26|37|39|41|60|61|62|63|80|99',
> '04|07|09|17|19|27|28|29|39|41|46|51|52|54|57|58|60|68|74|80|99'
> );
>
> # Turn data into a list of lists
> @data = "" { [ split /\|/ ] } @data;
>
> my $lc = List::Compare->new( @data );
>
> print "Intersection: ", join ",", $lc->get_intersection;
>
>
> --
> Mark Thomas
> Internet Systems Architect
> _______________________________________
> BAE SYSTEMS Information Technology
> 2525 Network Place
> Herndon, VA  20171  USA
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>
>
> __________________________________________________________
> Message transport security by GatewayDefender.com
> 2:32:31 PM ET - 11/10/2004
>

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to