In Chapter 4, Section 4.8 (Computing Union, Intersection, or Difference of Unique Lists), the Perl Cookbook provides this technique for getting the intersection of two lists
Array::Utils is what you're looking for.
use Array::Utils qw(:all);
my @a = qw( a b c d );
my @b = qw( c d e f );
my @isect = intersect(@a, @b);
print join(",",@isect) . "\n";
This produces the expected output of
c,d
Edit: I didn't notice that you wanted this done case-insensitively. In that case, you can replace @a
with map{lc}@a
(and likewise with @b
).