use strict; use warnings; my @wanted = qw(1101077781172 1101077781180 1101077781183); my %match = map {$_ => 1} @wanted; while () { chomp; my (@fields) = split; next unless @fields >= 3; print "$_\n" if exists $match{$fields[0]}; } __DATA__ 1101077781160 1101077783656 bothChaff 1101077781161 1101077783657 bothChaff 1101077781162 1101077783658 bothChaff ... #### 1101077781172 1101077783668 bothChaff 1101077781180 1101077783676 oneDegen