I actually have a module partially written that allows one to modify numbered captures.

One problem with changing Perl itself to allow either named or numbered captures to not be read-only, is that Perl is prone to make such captures actually point to a copy of the original string.

FYI, allowing modification of such interleaved substrings is an interesting and rather complex problem (especially the edge cases). But I'll write that stuff up later.

Update: Upon reading more of the thread, I see that what was wanted was to be able to modify a capture variable as a glorified temporary variable. To be clear, what my module does is allow one to modify the numbered capture such that it modifies the string variable that the regex was matched against (while ensuring all of the other numbered captures are properly made aware of the update and, if sanely possible, remain modifiable).

- tye        


In reply to Re: Why are 5.10's named captures read only? (tuit) by tye
in thread Why are 5.10's named captures read only? by blazar

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.