in reply to Comparing between multiple sets of data
This seems to work:
#!/bin/perl -w use strict; my @array = ([1,2,3],[5,5,6],[1,4,6]); # nb => number of arrays in which the number is found my %in_array; foreach my $array (@array) { # the keys of %unique_for_array are the (unique) numbers in the ar +ray my %unique_for_array= map { $_, 1} @$array; # now use those unique numbers to count $in_array{$_}++ foreach keys %unique_for_array; } # get the duplicates my @duplicates= grep { $in_array{$_} > 1 } keys %in_array; print "duplicates: ", join( ', ', @duplicates), "\n";
|
|---|