in reply to Re: Decompose a String into Tuples (Faster and Compact Way)
in thread Decompose a String into Tuples (Faster and Compact Way)

Dear Roy Johnson,

Taking the benefit of incredible speed that your code provide. How can I modify your code above such that given this string:
my $s1 = 'X -4 Y 3 Z';
It will decompose into a such AoA:
$VAR = [["X", -4, "Y"], ["Y",3,"Z"]];
Thanks so much beforehand. Really hope to hear from you again.

---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re^3: Decompose a String into Tuples (Faster and Compact Way)
by Roy Johnson (Monsignor) on Oct 16, 2005 at 13:43 UTC
    You just want to split each of the extracted tuple-strings:
    my $aref = [ map [split], $s1 =~ /(?=([a-z]\s*(?:\S+\s*){2}))\S+\s*/gi + ];

    Caution: Contents may have been coded under pressure.