#! C:\Perl\bin\perl -w use strict; use warnings; open my $LIST, '<', "list.txt"; my @mylist = <$LIST>; open my $FILE, '<', "file.txt"; my @myfile = <$FILE>; foreach my $file (@myfile) { chomp $file; my @temp = split (/\t/, $file); foreach my $list (@mylist) { chomp $list; if ($temp[1] eq $list) { print "$file\n" } } }