On Mon, Aug 13, 2001 at 04:34:20PM -0400, Greg London wrote:
> This works as expected:
>
> > $string =~ m/e/mcg;
> > print "position is ".pos($string)."\n";
>
>
> This gets confused and prints null for position.
>
> > my @matches = $string =~ m/e/mcg;
> > print "position is ".pos($string)."\n";
>
> just because I capture the matches in my pattern,
> shouldn't mean my pos() value gets hosed, should it?
m//g only sets pos() when it's in scalar context. I don't think pos()
would generally be useful after a match in list context.
Note that your second example actually prints whatever pos() was set to
before the match in list context; the list context match doesn't affect
pos() at all.
Ronald