use strict; use warnings; while (<DATA>) { if ( /^StartTr1/ .. /^oflTr1/ ) { print unless (/^StartTr1/) or (/^oflTr1/); } } __DATA__ StartTr1 sample 1 sample 1 sample 1 sample 1 SAMPLE 1 oflTr1 nothing nothing nothing StartTr1 sample 2 sample 2 sample 2 sample 2 sample 2 last line before sample 2 oflTr1 junk junk junk
prints:
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
In reply to Re: Print all lines between two keywords
by toolic
in thread Print all lines between to keywords
by perlnewbie9292
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |