in reply to Question about regex.

A couple of points that haven't been mentioned yet:

Replies are listed 'Best First'.
Re^2: Question about regex.
by GrandFather (Saint) on Sep 29, 2020 at 20:11 UTC
    "local $/="";
    "If you wanted to format your regex nicely and have whitespace ignored, you could use the /x modifier"

    Anyone else feel a dissonance here? I'd format the assignment (yes, it is an assignment) as:

    local $/ = "";

    On first glance the assignment looks like $/= "" to me and that's not right. An eye blink later it turns into $ /= "" which doesn't work either. It's only after two glances and a hard look that it resolves into $/ = "";. Using white space to reduce cognitive load is a Good Thing

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
      Anyone else feel a dissonance here?

      Yes, you do have a point, I didn't need to be stingy with those two spaces. Though I did say "If you wanted to format your regex nicely", and not "you should format your regex nicely" (and noone else in the thread used /x either) ;-)

      Edit: missed a word on c&p

        I get a bit touchy about white space. Many of my work mates eschew spaces wherever possible and at the other extreme I see stuff like function( param1 , param2 , param3 ); which hurts my brain almost as much as no spaces. My rule of thumb is to use white space where possible as you would for prose on the basis that that is what we are most used to parsing so we get a fair bit of the parsing work essentially for free.

        Interestingly regexen are something of an exception for me. Unless they are fairly complicated I don't use /x. When I do use /x I often break the regex up over several lines and comment each part. Mostly though I keep the regexen fairly simple and do complicated stuff where it's easier to maintain.

        Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond