in reply to pos()atively mysterious.
However if we set $var = 'the quick brown fox jumped' then the same code gets into some endless loop whereas $var = 'The quick brown fox jump x' loops twice OK.
I'm not quite sure whether this is defined behaviour but it caused me some head scratching when trying to parse some text into name/value bits. There are of course any number of work arounds, but its a bit of a surprise when misformed data causes your code to hang.$var = 'the quick brown fox'; while( $var =~ m/([aeiou])/g ) { print "\n$var Matched '$1' \@ pos:", pos($var), "\n"; $var =~ m/x/g; print "$var : Matched X \@ pos:", pos($var), "\n"; }
Dingus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pos()atively dangerous.
by diotalevi (Canon) on Dec 16, 2002 at 14:15 UTC |