in reply to Re: /g matches not really global in scalar context!
in thread /g matches not really global in scalar context!

For the record I didnt use this example as it would be just too perlish to special case /g inside of a while loop. I used the non while version to show that this is a general case, and not a consequence of using a while. That way people dont associate this use of /g with a while loop, especially as 99.9999% of the time one finds it in such a context.

---
$world=~s/war/peace/g

  • Comment on Re^2: /g matches not really global in scalar context!

Replies are listed 'Best First'.
Re^3: /g matches not really global in scalar context!
by Aristotle (Chancellor) on Nov 14, 2005 at 20:55 UTC

    To chain matches, you’d usually use /gc, not just /g. Plain /g in scalar context is almost always associated with repeated match attempts for the same pattern.

    Makeshifts last the longest.