Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Unescaped left brace in regex is passed through in regex

by Aldebaran (Curate)
on Jun 11, 2022 at 02:59 UTC ( [id://11144681]=note: print w/replies, xml ) Need Help??


in reply to Re: Unescaped left brace in regex is passed through in regex
in thread Unescaped left brace in regex is passed through in regex

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

There's a lot of disambiguation to do along these lines, and your response helped me piece this all together. I finally found the syntax I was looking for in the REPL:

DB<7> $b="\N{U+007B}" + DB<8> p $b + { DB<9>
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.)

Are you suggesting that a person sandbox the application and boil the perl version up?

Replies are listed 'Best First'.
Re^3: Unescaped left brace in regex is passed through in regex
by haukex (Archbishop) on Jun 11, 2022 at 15:47 UTC
    $b="\N{U+007B}"

    Note that's a double-quoted string, and you don't need to escape {'s there - unless of course you mean using that escape in a regex, and while /\N{U+007B}/ certainly works, it's a whole lot longer than the equivalent /\{/...

    Are you suggesting that a person sandbox the application and boil the perl version up?

    Yes, that's exactly the suggestion (though "test environment" would be more accurate than "sandbox"). It's of course a bit of work and may seem like overkill; many people do end up not doing this and jumping several years into the future like in this case. But when that then leads to problems (like in this case), one way to debug is to gradually step up the Perl versions so one catches all the deprecation warnings before they become fatal errors or confusing syntax errors.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11144681]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found