Roboticus@Waubli ~ $ cat t.pl use strict; use warnings; # Valid records must have these fields my @required = qw( name timestamp dl_retransmits_pct dl_throughout ); while (my $line = ) { my @missing = grep { $line !~ /$_/ } @required; if (@missing) { print "record $. missing fields: ", join(", ", @missing), ".\n"; } } __DATA__ name timestamp dl_retransmits_pct dl_throughout foo name dl_throughout timestamp dl_retransmits_pct name timestamp dl_retransmits_pct dl_throughout Roboticus@Waubli ~ $ perl t.pl record 3 missing fields: dl_throughout. record 4 missing fields: name, timestamp, dl_retransmits_pct.