in reply to Convert string to data structure

my $str = "1. ...... AB_CD 1.1 ...... EF_GH 1.2 .... IJ_KL_MN 2. ..... +....... OPQR"; my( undef, %chap ) = split /\s*(\d+\.\d*)\s*\.+\s*/, $str;

Works.

- tye        

Replies are listed 'Best First'.
Re^2: Convert string to data structure (split)
by Athanasius (Archbishop) on Sep 21, 2012 at 16:03 UTC

    tye, I think you need to change:

    split/\s+(\d+ ... # ^

    to

    split/\s*(\d+ ... # ^

    otherwise it fails to capture '1.' => 'AB_CD'.

    Athanasius <°(((><contra mundum

      I did. Three times. Not sure how it still ended up not submitted that way. Thanks for pointing it out. :)

      - tye