in reply to Re: comparing 2 lists
in thread comparing 2 lists

You've put the table loop on the outside, which is good. If it was on the inside, you'd be compiling a lot of regexps for nothing. But it can be taken a step further.

my $tableList = map qr/$_/i, join '|', map quotemeta, @tableList; for my $Q (@fileList) { push @tableUsed, $Q =~ /$tableList/g; }

The OP might want to remove duplicates from @tableUsed.

my $tableList = map qr/$_/i, join '|', map quotemeta, @tableList; my %tableUsed; for my $Q (@fileList) { for my $W ($Q =~ /$tableList/g) { ++$tableUsed{$W}; } } my @tableUsed = sort keys %tableUsed;