in reply to Re^4: Regex question - negatives
in thread Regex question - negatives
..while this only prints out the "test new line" one for some reason?
while ($test =~ s{$re}{}ge) {
print "BLA: $1 \n";
}
That is because s///g ignores context and just does all the replacements at once leaving the last match in $1.
But m//g in scalar context will iterate through each match every time it is called in scalar context so that in a while loop $1 will contain each match in turn.
|
|---|