while (my $line = <$fh>) { chomp $line; ($line =~ /start text|^\+/) && print "$line\n"; }