http://qs1969.pair.com?node_id=450697


in reply to I resolve to finally grok and use the regex option...

I routinely use g, s, and sometimes even i, e, x, c. I even know what o and m means, but I haven't find any use for them.

However, I am all confused when I write regexen in ruby, because the m option for ruby regexps is the same as the s in perl. Even worse, if you write s by habit, you don't even get a warning because it has a different meaning.

Update 2007 jan 22: since then, I've found a use for m as well.

Replies are listed 'Best First'.
Re^2: I resolve to finally grok and use the regex option...
by jhourcle (Prior) on Apr 24, 2005 at 01:08 UTC

    You might not use them because there are other ways to get around them. For instance, with qr//, you don't need to ever use m//o. m//m can be useful when you're trying to read in data records, but you can also match on the line seperator with a lookahead or lookbehind assertion. (or line seperator or \A or \Z, it you might match the very beginning or very end)

Re^2: I resolve to finally grok and use the regex option...
by etcshadow (Priest) on Apr 24, 2005 at 05:20 UTC
    <s>You use /c? What is it, and why can't I find anything about it in perlre?</s>

    Update: never mind. Resolved in the CB. For any others curious, it's in perlop, not perlre.

    ------------ :Wq Not an editor command: Wq
      This was new to me too. I found some additional information on /c in perlretut.

      /c (in conjunction with /g) is great for tokenization. See Using Multiple m/\G.../gc to Tokenize for an example. There's another example in perlfaq.

      I've actually used all of the options listed in the poll.