http://www.perlmonks.org?node_id=994923

Dirk80 has asked for the wisdom of the Perl Monks concerning the following question:

Hello

possibly this is an easy thing. But I don't get it. So I'm interested in your answers.

Here my string:

my $str = "1. ...... AB_CD 1.1 ...... EF_GH 1.2 .... IJ_KL_MN 2. ............ OPQR";

And here what I would like to have:

my $VAR1 = [{'chapter' => 1, 'name' => 'AB_CD'},{'chapter' => 1.1,'nam +e' => 'EF_GH'},{'chapter' => 1.2,'name' => 'IJ_KL_MN'},{'chapter' => +2,'name' => 'OPQR'}];

I tried a lot of things with split. And I often came near to the desired result. But as said before. I didn't get it completely correctly.

Example I tried: split(/\s\.+\s/, $str);

Thanks alot for your help.

Greetings, Dirk