I suspect that $1{$2} is recognized as addressing an associative array, but I could not find any mention in the documentation about such an expansion in the substitution part of a RE.

See Quote and Quote like Operators:

... In the following table, a {} represents any pair of delimiters you choose.
Customary Generic Meaning Interpolates ... s{}{} Substitution yes* ... * unless the delimiter is ''.

Where "interpolates" means the same thing as what happens to strings in double quotes, like "$hash{$key}", or, in your case, "$1{$2}". The error message gives you a hint: "Use of uninitialized value within %1 in substitution iterator" - so yes, $1{$2} means the same as $x{$y}, that is, access the hash %1 and fetch the key named by the string stored in $2. Your solution of adding the backslash is fine.


In reply to Re: Brace in the replacement part of a regular expression substitution by haukex
in thread Brace in the replacement part of a regular expression substitution by luc.bouge

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.