in reply to Print all lines between to keywords
Note that the while (<DATA>) { ... } form given by toolic is preferred for this sort of file processing. I have assumed that there is a need to read the entire file before processing it, as is done in the OP, and have given the code in this form.>perl -wMstrict -e "open my $fh, '<', '806007.dat' or die qq{opening: $!}; my $linesFromFile = [ <$fh> ]; close $fh or die qq{closing: $!}; for (@$linesFromFile) { next unless my $seq_n = /^StartTr1/ .. /^oflTr1/; print unless $seq_n < 2 or $seq_n =~ /E0$/; } " sample 1 sample 1 sample 1 sample 1 SAMPLE 1 sample 2 sample 2 sample 2 sample 2 sample 2 last line before sample 2
|
|---|