According to perlop
In scalar context, each execution of m//g finds the next match, returning true if it matches, and false if there is no further match. The position after the last match can be read or set using the pos() function;
But the following snippet
while( 'the quick brown fox' =~ m/(.)/g) { print "Matched '$1' \@ pos:", pos(); }
produces
Matched 't' @ pos:Use of uninitialized value in print at C:\test\temp. +pl line 1. Matched 'h' @ pos:Use of uninitialized value in print at C:\test\temp. +pl line 1. Matched 'e' @ pos:Use of uninitialized value in print at C:\test\temp. +pl line 1. ...
What am I doing wrong?
Examine what is said, not who speaks.
In reply to pos()atively mysterious. by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |