If you trust that your data will be well-formed, you can simply match what you want to keep instead of splitting the string:
my %values = ($string =~ /(SECTION \d+)\s+(.*?)/sg);
That idea doesn't work :-/ :
my $string = <<STR; SECTION 1 This is section 1 SECTION 2 This is section 2 STR use Data::Dumper; my %values = ($string =~ /(SECTION \d+)\s+(.*?)/sg); print Dumper \%values;
In reply to Re: Regex to array
by Corion
in thread Regex to array
by kepler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |