in reply to Unescaped left brace in regex is passed through in regex
Is there any easy way to maintain compatibility?
The best way is to escape the braces. From perldeprecation, reorganized a bit:
Forcing literal { characters to be escaped will enable the Perl language to be extended in various ways in future releases. ...
Literal uses of { were deprecated in Perl 5.20, and some uses of it started to give deprecation warnings since. These cases were made fatal in Perl 5.26. Due to an oversight, not all cases of a use of a literal { got a deprecation warning. Some cases started warning in Perl 5.26, and were made fatal in Perl 5.30. Other cases started in Perl 5.28, and were made fatal in 5.32. ...
The simple rule to remember, if you want to match a literal { character (U+007B LEFT CURLY BRACKET) in a regular expression pattern, is to escape each literal instance of it in some way. Generally easiest is to precede it with a backslash, like \{ or enclose it in square brackets ([{]). If the pattern delimiters are also braces, any matching right brace (}) should also be escaped to avoid confusing the parser, for example, qr{abc\{def\}ghi} ...
In general, when upgrading Perl versions, two things are important: have a test environment where you can try out upgrading Perl before doing it in a live environment, and second, upgrade Perl releases step by step, i.e. 5.10, 5.12, 5.14, and so on (e.g. perlbrew makes this easy), because as you can tell from the above, the policy is to have breaking changes give deprecation warnings for at least one major release before making them fatal. (Update: Side note: 5.10.1 to 5.26.3 is a jump of over 9 years of development, with 5.26.3 still being 3.5 years older than the current 5.36.0.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unescaped left brace in regex is passed through in regex
by Aldebaran (Curate) on Jun 11, 2022 at 02:59 UTC | |
by haukex (Archbishop) on Jun 11, 2022 at 15:47 UTC |