Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Driving the Engine right off the road

by ysth (Canon)
on Aug 24, 2025 at 14:58 UTC ( [id://11166100]=note: print w/replies, xml ) Need Help??


in reply to Re: Driving the Engine right off the road
in thread Driving the Engine right off the road

Note that I kept your $ but I hate it, because without /m it is rarely used to intentionally do what it actually does (match either the end of the string or before a newline at the end of a string). If your data has no newlines, use \z (match only at the end of the string). If your data ends with newlines, use \n (or \n\z if your string may have internal newlines that should not match). Then your code doesn't mislead about what the data looks like.

Replies are listed 'Best First'.
Re^3: Driving the Engine right off the road
by Intrepid (Curate) on Aug 24, 2025 at 21:55 UTC

    It's weird. I lost some good habits when I took my 10-year break from programming, and using \z instead of $ in regexen is one of them. Since you pointed it out, I think my fingers will do the right thing from now on. In this case it wouldn't matter because my strings are all keys from %ENV and would never contain an embedded newline. But regaining (and retaining) good coding habits is important.

        – Soren

    never

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2026-01-18 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (121 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.