Have you considered splitting the string on "), XX("? Something like:

@chunks = split /\), ([A-Z][A-Z])\(/, $input;

That'll give you all the values interspersed with the prefixes (with the first and last elements being wacky because you matched on the stuff that goes between each value).

In fact, you could make the split pattern a bit more complex, to separate out the first "AA(" and the last ")":

@chunks = split /(?: (?:^|\),\s) ([A-Z][A-Z])\( | \)$)/x, $input; shift @chunks; # remove extra blank element at front

Then you can use part from List::MoreUtils to partition the list into prefixes and values, or you could just assign it to a hash and use it directly:

use List::MoreUtils qw(part); my @chunks = ...; # as above shift @chunks; # as above my $ix = 0; my ($prefixes,$texts) = part {++$ix % 2} @chunks; # or my %text = @chunks; say "Text value AF is $text{AF}";

In reply to Re: Character Text Delimiters by Sue D. Nymme
in thread Character Text Delimiters by Ninthwave

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.