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