in reply to Re: Regular Expressions Challenge
in thread Regular Expressions Challenge

This code is all well and good, except it takes the information after the end of each comments section also. I need to take only the information within each comments section (e.g. between ===Comments=== and =Microarray Data=). Sorry if that wasn't clear.

Replies are listed 'Best First'.
Re^3: Regular Expressions Challenge
by JavaFan (Canon) on May 18, 2010 at 13:33 UTC
    my @data = split /\n/, $str; my @section; my $i = 0; while (@data) { $_ = shift @data; if (/^===Comments===$/) { while (@data) { $_ = shift @data; last if /^=/; $section[$i] .= "$_\n"; } $i++; } }