From 9af0006bddac3108a478ad921119bb41c07b088e Mon Sep 17 00:00:00 2001 From: Zsban Ambrus Date: Sun, 9 Jun 2013 09:26:22 -0400 Subject: [PATCH] document the /p flag and related variables in delta --- pod/perl5100delta.pod | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pod/perl5100delta.pod b/pod/perl5100delta.pod index 4e5c6d3..10d71d6 100644 --- a/pod/perl5100delta.pod +++ b/pod/perl5100delta.pod @@ -200,6 +200,23 @@ logically match their complements. C<\R> matches a generic linebreak, that is, vertical whitespace, plus the multi-character sequence C<"\x0D\x0A">. +=item Optional pre-match and post-match captures with the /p flag + +There is a new flag C

for regular expressions. Using this +makes the engine preserve a copy of the part of the matched string before +the matching substring to the new special variable C<${^PREMATCH}>, the +part after the matching substring to C<${^POSTMATCH}>, and the matched +substring itself to C<${^MATCH}>. + +Perl is still able to store these substrings to the special variables +C<$`>, C<$'>, C<$&>, but using these variables anywhere in the program +adds a penalty to all regular expression matches, whereas if you use +the C

flag and the new special variables instead, you pay only for +the regular expressions where the flag is used. + +For more detail on the new variables, see L; for the use of +the regular expression flag, see L and L. + =back =head2 C -- 2.7.4