my ($file1, $file2) = qw(file1 file2); open INDAT, "<", $file1 or die "Cannot open ($file1) for reading: $!"; open INCOMP, "<", $file2 or die "Cannot open ($file2) for reading: $!"; while (defined (my $line = )) { chomp $line; # remove newline my @array = split /\t/, $line; while (defined (my $line = )) { chomp $line; my @probes = split /\t/, $line; # using \Q and \E to avoid having regex meta character problems # see "perldoc perlre" if ($array[0] =~ /\Q$probes[1]\E/i) { print "Found $probes[1]\n"; } } } close INCOMP; close INDAT;