perlquestion
BrowserUk
<p>According to [perlop]
<p><blockquote><i>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;</i></blockquote>
<p>But the following snippet
<p><code>
while( 'the quick brown fox' =~ m/(.)/g) {
print "Matched '$1' \@ pos:", pos();
}
</code>
<p>produces
<p><code>
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.
...
</code>
<p>What am I doing wrong?
<hr>
<font size=1>
<p>Examine what is said, not who speaks.</p></font>