On Fri, Nov 26, 2004 at 10:41:34PM -0500, Stas Bekman wrote:
> If the match has failed C<undef> is returned, unless the /c option
> was used (which may still return C<undef> if pos() has never returned
> a defined value.
>
> or something like that?
Something like this?
Change 23550 by [EMAIL PROTECTED] on 2004/11/27 14:43:37
Clarify the return values of pos, particularly 0 and undef, as
suggested by Stas Bekman
Affected files ...
... //depot/perl/pod/perlfunc.pod#448 edit
Differences ...
==== //depot/perl/pod/perlfunc.pod#448 (text) ====
@@ -3828,9 +3828,14 @@
=item pos
Returns the offset of where the last C<m//g> search left off for the variable
-in question (C<$_> is used when the variable is not specified). May be
-modified to change that offset. Such modification will also influence
-the C<\G> zero-width assertion in regular expressions. See L<perlre> and
+in question (C<$_> is used when the variable is not specified). Note that
+0 is a valid match offset, while C<undef> indicates that the search position
+is reset (usually due to match failure, but can also be because no match has
+yet been performed on the scalar). C<pos> directly accesses the location used
+by the regexp engine to store the offset, so assigning to C<pos> will change
+that offset, and so will also influence the C<\G> zero-width assertion in
+regular expressions. Because a failed C<m//gc> match doesn't reset the offset,
+the return from C<pos> won't change either in this case. See L<perlre> and
L<perlop>.
=item print FILEHANDLE LIST