in reply to matching and writing multiple line blocks
This puts each new section into file001, file002, file003, and so on, and anything outside those sections into file000.my $name = "file000"; open STDOUT, ">>file000" or die "cannot append to file000: $!"; while (<>) { if (/Experiment/) { open STDOUT, ">>".(++$name) or die "Cannot append to $name: $!"; } print; if (/Reagent Lot/) { open STDOUT, ">>file000" or die "Cannot re-append to file000: $!"; } }
Will that do, or are there other secret requirements? {grin}
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: matching and writing multiple line blocks
by Adam (Vicar) on Sep 01, 2000 at 19:40 UTC | |
by merlyn (Sage) on Sep 01, 2000 at 19:55 UTC |