I thought about using (?{$N=1}) etc. in each branch, but shy away from the "highly experimental" feature that may be changed without notice.

The if to the array is interesting, but won't work for me because I'm doing a substitution, not just a match. The docs give an /G../gc idiom for lexing, but there is no equivilent for altering the parts not just detecting them.

As for kludgeing something together, since we're getting away from funny globals altogether, how about making a bold move and providing a variable named $Regexp::last_paren_match_count, or better yet @Regexp::matches that aliases the same values as $1, $2, etc. then they can be manipulated as an array in all the normal ways, index with -1, get array length, etc.

—John


In reply to Re: Re: What's like $+ but not gives the ordinal? by John M. Dlugosz
in thread What's like $+ but not gives the ordinal? by John M. Dlugosz

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.