perldoc perlre says this
(If a curly bracket occurs in any other context and does not form part of a backslashed sequence like \x{...} , it is treated as a regular character. However, a deprecation warning is raised for all such occurrences, and in Perl v5.26, literal uses of a curly bracket will be required to be escaped, say by preceding them with a backslash ("{" ) or enclosing them within square brackets ("[{]" ). This change will allow for future syntax extensions (like making the lower bound of a quantifier optional), and better error checking of quantifiers.)
OK, so the following prints the deprecation message.
perl -lE 'm/x{x}/'
why the following isn't?
perl -lE 'm/x({x})/'
e.g. in the capture group is the { allowed unescaped? Probably not because the
perl -lE 'm/x(x{x})/'
also prints the warning.
So, what is the exact "logic"?
Ps: i will escape every literal {, but wondering about the rationale behind the above.
Aucun commentaire:
Enregistrer un commentaire