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.)


In reply to Re: Unescaped left brace in regex is passed through in regex by haukex
in thread Unescaped left brace in regex is passed through in regex by gzh

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.