in reply to Re^3: How to extract a pattern in Perl regex?
in thread How to extract a pattern in Perl regex?

... caveat ... is to remember to use the /s modifier if the text you are extracting might contain \n.

Simpler still is to always use  /s (along with  /x and  /m in a consistent  /xms modifier tail) on every  qr// m// s/// you write. Then the rule is simply "Dot matches all." Period.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^5: How to extract a pattern in Perl regex?
by hippo (Archbishop) on May 01, 2020 at 10:50 UTC

    We've had this conversation before. Let's agree to disagree. :-)

      As I was finishing my reply, it began to dawn on me that we had, in fact, had this discussion before. Anyway, it seemed that it might still be useful to a novice monk to be exposed to the disagreement.


      Give a man a fish:  <%-{-{-{-<

        For my part, I consider automatic inclusion of flags a kind of micro-cargo-culting. If they are there, my assumption is they are necessary for the code to operate correctly. That means that if they are not actually needed, my assumption may lead me to possibly misunderstand the source they will operate upon or need to investigate or read the regex a lot more closely than I normally would. Probably not a big, or any, deal in general but in the cases it might be, it will make me angry with the original dev. That said, I habitually use some constructions that violate my stated policy of the necessary, like +shift, so I am not really one to talk. :P