in reply to Matching text between line 0 and 4
or just read line by line, resetting as you go:undef $/; my $whole_thing = <TEST>; my @chunks = split /(?=^\w)/, $whole_thing; my @chunk_lines = map { [split /\n\s*/] } @chunks;
my @chunk_lines; my $this_chunk = 0; while (<TEST>) { if (/^\w/) { ++$this_chunk } else { push @{$chunk_lines[$this_chunk]}, $_ } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching text between line 0 and 4
by JediWizard (Deacon) on Mar 17, 2005 at 20:01 UTC |