While migrating code from 5.16 to 5.24 I noticed this deprecation warning to be inconsistent

according to perldelta all literal left braces should be escaped now.

A literal "{" should now be escaped in a pattern

If you want a literal left curly bracket (also called a left brace) in a regular expression pattern, you should now escape it by either preceding it with a backslash ("\{") or enclosing it within square brackets "[{]" , or by using \Q; otherwise a deprecation warning will be raised. This was first announced as forthcoming in the v5.16 release; it will allow future extensions to the language to happen.

but the following code only warns for the second left brace one. Not escaping the first one doesn't throw a warning.

Am I missing something or is this a bug?

DB<31> (my $x="{{abc}}") =~ s/{{/[[/g; print $x Unescaped left brace in regex is deprecated, passed through in regex; +marked by <-- HERE in m/{{ <-- HERE / at (eval 40)[c:/Perl_524/lib/pe +rl5db.pl:737] line 2. + at (eval 40)[c:/Perl_524/lib/perl5db +.pl:737] line 2. eval 'no strict; ( +$@, $!, $^E, $,, $/, $\\, $^W) = @DB::saved;package main; $^D = $^D | + $DB::db_stop; (my +$x="{{abc}}") =~ s/{{/[[/g; print $x; + ' called at c:/Perl_524/lib/perl5db.pl line 737 + DB::eval called at c:/Perl_524/lib/perl5db. +pl line 3131 DB::DB called at -e line 1 + [[abc}} + + DB<32> (my $x="{{abc}}") =~ s/{\{/[[/g; print $x + [[abc}}

PS: sorry for the missing \n in the code, but copying from win-cmd is a PITA

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!


In reply to Only sometimes deprecated? "Unescaped left brace in regex is deprecated" by LanX

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.