C:\tmp\files>perl -nE" @o=() if /PATTERN1/; push @o,$_; say qq(<@o>) if /PATTERN3/ " input2 C:\tmp\files>