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!
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |