@A = ("Red", "Green", "Yellow"); @B = ("Yellow", "Black","Yellow","Red", "White", "Yellow"); #### > Red at index 3 > Green is missing > Yellow at index 0, 2 and 5 > Elements from B were detected 4 times in A #### foreach $x (@A){ foreach $y (@B){ if ($y eq $x){ print "$y\n"; } elsif ($x ne$y){ print "$x"; } } }