while(defined(my $line = <$infile>)) { next if($line =~ /^From (\w+)$/ ... $line =~ /^From (\w+)$/); # ... }