Help for this page

Select Code to Download


  1. or download this
    undef $/;
    my $whole_thing = <TEST>;
    my @chunks = split /(?=^\w)/, $whole_thing;
    my @chunk_lines = map { [split /\n\s*/] } @chunks;
    
  2. or download this
    my @chunk_lines;
    my $this_chunk = 0;
    ...
        if (/^\w/) { ++$this_chunk }
        else { push @{$chunk_lines[$this_chunk]}, $_ }
    }