It looks like you may be trying to print out any lines returned from your netstat command that have the strings "invalid headers" or "packets dropped" in them. If so, I think this may be something that will work for you...
my @netstat = `netstat -s`;
my @matches=("invalid headers", "packets dropped");
my $matches = join('|', @matches);
foreach (@netstat) {
print if /$matches/;
}
However, if you go through alot of records this will be slow as it has to reparse the regular expression over and over. If your regex (list of strings to match) is truely variable and you process lots of records then it might be more efficient to assemble some perl code and eval it. The advanced perl book ( the one with the panther on it ) has a good example in it in the eval chapter.