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

This is fully intended. It’s there so you can say

while( m{ \b aiutino \b }gix ) { warn "Argh!" }

Makeshifts last the longest.

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

    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

      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.