summaryrefslogtreecommitdiff
path: root/pod/perlop.pod
diff options
context:
space:
mode:
authorbrian d foy <brian.d.foy@gmail.com>2010-10-28 01:49:57 -0500
committerbrian d foy <brian.d.foy@gmail.com>2010-10-28 01:49:57 -0500
commit3dd93342ac0ba3088f730b3be9b9e62422b1e414 (patch)
treea5bc64d29f18c25970268ff401bf881e493eedfc /pod/perlop.pod
parent650314380535ade9e2163211933953f5a54fe086 (diff)
downloadperl-3dd93342ac0ba3088f730b3be9b9e62422b1e414.tar.gz
Defer to perlfunc on \G and pos()
Diffstat (limited to 'pod/perlop.pod')
-rw-r--r--pod/perlop.pod28
1 files changed, 15 insertions, 13 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod
index 4e1d217770..93e16878d0 100644
--- a/pod/perlop.pod
+++ b/pod/perlop.pod
@@ -1425,31 +1425,33 @@ $Etc. The conditional is true if any variables were assigned, i.e., if
the pattern matched.
The C</g> modifier specifies global pattern matching--that is,
-matching as many times as possible within the string. How it behaves
-depends on the context. In list context, it returns a list of the
+matching as many times as possible within the string. How it behaves
+depends on the context. In list context, it returns a list of the
substrings matched by any capturing parentheses in the regular
-expression. If there are no parentheses, it returns a list of all
+expression. If there are no parentheses, it returns a list of all
the matched strings, as if there were parentheses around the whole
pattern.
In scalar context, each execution of C<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; see L<perlfunc/pos>. A failed match normally resets the
+The position after the last match can be read or set using the C<pos()>
+function; see L<perlfunc/pos>. A failed match normally resets the
search position to the beginning of the string, but you can avoid that
-by adding the C</c> modifier (e.g. C<m//gc>). Modifying the target
+by adding the C</c> modifier (e.g. C<m//gc>). Modifying the target
string also resets the search position.
=item \G assertion
You can intermix C<m//g> matches with C<m/\G.../g>, where C<\G> is a
-zero-width assertion that matches the exact position where the previous
-C<m//g>, if any, left off. Without the C</g> modifier, the C<\G> assertion
-still anchors at pos(), but the match is of course only attempted once.
-Using C<\G> without C</g> on a target string that has not previously had a
-C</g> match applied to it is the same as using the C<\A> assertion to match
-the beginning of the string. Note also that, currently, C<\G> is only
-properly supported when anchored at the very beginning of the pattern.
+zero-width assertion that matches the exact position where the
+previous C<m//g>, if any, left off. Without the C</g> modifier, the
+C<\G> assertion still anchors at C<pos()> as it was at the start of
+the operation (see L<perlfunc/pos>), but the match is of course only
+attempted once. Using C<\G> without C</g> on a target string that has
+not previously had a C</g> match applied to it is the same as using
+the C<\A> assertion to match the beginning of the string. Note also
+that, currently, C<\G> is only properly supported when anchored at the
+very beginning of the pattern.
Examples: