in reply to Matching text between line 0 and 4

Slurp, split, split each piece:
undef $/; my $whole_thing = <TEST>; my @chunks = split /(?=^\w)/, $whole_thing; my @chunk_lines = map { [split /\n\s*/] } @chunks;
or just read line by line, resetting as you go:
my @chunk_lines; my $this_chunk = 0; while (<TEST>) { if (/^\w/) { ++$this_chunk } else { push @{$chunk_lines[$this_chunk]}, $_ } }

Caution: Contents may have been coded under pressure.

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

    It is probably better do do the slurp like this:

    my $whole_thing = do{local $/; <TEST>};

    A truely compassionate attitude towards other does not change, even if they behave negatively or hurt you

    —His Holiness, The Dalai Lama