in reply to Re: pos()atively mysterious.
in thread pos()atively mysterious.

Erm. That doesn't help. The following program produces exactly the same errors?

my $str = 'the quick brown fox'; while( $str =~ m/(.)/g) { print "Matched '$1' \@ pos:", pos(); }

I'm not sure why you thought that use a variable rather than a constant would change anything as I am not attempting to modify the data in anyway, I'm just printing the char captured (successfully) and the position at which it was found (unsuccessfully).

Basically, the pos() function is never returning anything but undef, despite the fact that the m//g is obviously remembering the last position matched as it print each successive char on subsequent iterations.

Examine what is said, not who speaks.