in reply to S And M -- modifiers, that is...

The way I remember what /s and /m do is like this. I know that they change the behaviour of regex metacharacters, but /s changes the behaviour of a single metacharacter (.) and /m changes the behaviour of multiple metacharacters (^ and $).

Don't know whether that will help anyone else.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: S And M -- modifiers, that is...
by thelenm (Vicar) on Feb 26, 2003 at 21:41 UTC
    I think that's a useful mnemonic. And it may help people to remember that those are the only things the /m and /s modifiers affect. The /s modifier only affects whether "." will match a newline. The /m modifier only affects whether ^ and $ can match at embedded newlines in the middle of a string. Other than that, everything else remains unaffected... in particular, "\n" and "\s" will always match newline characters, regardless of what modifiers are set.

    -- Mike

    --
    just,my${.02}

      don't understand. I actually printed out the size of @matches using "$#matches" and it all came out as 0. So how does the last non-greedy match work? thanks for explaining first.
Re: Re: S And M -- modifiers, that is...
by Cody Pendant (Prior) on Feb 25, 2003 at 21:51 UTC
    That's a useful one. It's actually in the book already, credited to an Andy Wardley.
    --
    “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
    M-J D