my $data_file = 'diana.txt'; my @identifiers = qw(1696 162x 1640); open(FILE, $data_file) || die("Could not open file: $!"); foreach $line(){ chomp $line; foreach $identifier(@identifiers){ if($line =~ /$identifier/i){ print "$line match\n"; } } } close FILE;