in reply to Matching words
I'm assuming you really mean simpler or easier to maintain rather than just shorter. I'd suggest something like this:
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 = <DATA>) { 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.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|