in reply to Bizarreness in ?PATTERN? and g
prints 1, 10 timesperl -le '$s="a1, a3 - a5\na11"; while ($i<10) { $i++; $s=~?a(\d+)?g; +print $1; }'
prints 1 3 5 11 11 1 3 5 11 11perl -le '$s="a1, a3 - a5\na11"; while ($i<10) { $i++; $s=~/a(\d+)/g; +print $1; }'
vs.
which prints 1 3 5 11perl -le '$s="a1, a3 - a5\na11"; $s=~?a(\d+)?g; print $1; $s=~?a(\d+)? +g; print $1; $s=~?a(\d+)?g; print $1; $s=~?a(\d+)?g; print $1;'
so the CODE ??g repeated in the SOURCE seems to behave differently then while (1..4) { ??g }, ie. the CODE ??g EXECUTED multiple times in the code.
I am confused.
Edited by Chady -- added code tags.
|
|---|