Don’t confuse yourself. foreach puts its expression into list context, so a /g match actually returns a list of all matches at once; of course the foreach then iterates over them one by one. The loop construct you want is while, which evaluates its condition in scalar context, so a /g match as the condition will return matches one by one.
Makeshifts last the longest.
In reply to Re^2: /g matches not really global in scalar context!
by Aristotle
in thread /g matches not really global in scalar context!
by blazar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |