in reply to Regex to array

Hi kepler,

a slight variation on Corion's proposal, tested here at the command line:

$ perl -e 'use strict; > use warnings; > use Data::Dumper; > > my $string = <<STR; STR> > SECTION 1 > > This is section 1 > > SECTION 2 > > This is section 2 > > STR > > > my %values = ($string =~ /(SECTION \d+)\s+([\w ]+)/mg); > print Dumper \%values; > ' $VAR1 = { 'SECTION 2' => 'This is section 2', 'SECTION 1' => 'This is section 1' };
Edit: My computer froze when I was about to post this. I had to reboot. When I could start again to post, I did not notice that Eily had posted another solution fixing Corion's initial attempt.