foreach my $id (@ids) { if ($id eq $NSC) { print MY $line; } } #### foreach my $row (@ids_table) { my @allcolumns = split /\t/, $row; if($count==0) { $myID= trim($allcolumns[0]); } else { $ids[$count] = trim($allcolumns[0]); } $count++; }