in reply to To regex or not to regex
I did use one regex to read the line that tells how many records to expect. I also took the liberty of changing the names of the output files with sprintf and a different prefix than the original file (just so i could delete my mistakes easier :D).
use strict; open(IN,'old_file.txt') or die; my $i = 1; while (<IN>) { if (/^(\d+)\s*$/) { open(OUT,'>new_file'.sprintf("%02d",$i++).'.txt') or die; do { $_ = <IN>; print OUT; } for (1..$1); } }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: To regex or not to regex
by abstracts (Hermit) on Mar 11, 2002 at 06:07 UTC | |
|
Re: (jeffa) Re: To regex or not to regex
by mndoci (Scribe) on Mar 11, 2002 at 06:11 UTC |