in reply to comparing 2 lists

You can use hashes (as the perlfaq4 suggests):

How do I compute the difference of two arrays? How do I compute the intersection of two arrays?

perdoc -q arrays

citromatik

Update:i.e. you can try something like this: (not tested)

my %count = (); my @tableused = (); foreach $W (@tableList,@fileList){ $count{$W}++ }; foreach $elem (keys %count) { push @tableused, $elem if $count{$elem} > 1; }

Update2:Your code seems syntactically valid, except for the equality test:

if($W==$Q)

If you are comparing strings you should use the "eq" op

if ($W eq $Q)