http://qs321.pair.com?node_id=1079635


in reply to compare 2 arrays for intersect diff and commmon values

It looks to me that this is not doing what you think:
my %count = (); foreach my $device (@current_list, @temp_devicelist) { $count{$device}++; }
as those arrays are in fact arrays of arrays. Try getting rid of that and putting my %count at the top of your sub and counting within the other loops:
my %count; # ... for ($n=0; $n < $size; $n++) { our $device=$current_list[$n][0]; $count{$device}++; } # ... for ($n=0; $n < $size; $n++) { our $tempdevicelinks=$temp_list[$n][0]; $count{$tempdevicelinks}++; } # ... my @difference = grep { $count{$_} == 1 } keys %count; my @intersect = grep { $count{$_} == 2 } keys %count; my @union = keys %count;
Then you can print out the values:
print "Difference:\n"; print "$_\n" for @difference; print "Intersect:\n"; print "$_\n" for @intersect; print "Union:\n"; print "$_\n" for @union;