Skip Menu |

This queue is for tickets about the Devel-SawAmpersand CPAN distribution.

Report information
The Basics
Id: 58468
Status: open
Priority: 0/
Queue: Devel-SawAmpersand

People
Owner: Nobody in particular
Requestors: bdfoy [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.31
Fixed in: (no value)



Subject: Update SawAmpersand docs for Perl 5.10's /p variables
I added some docs to SawAmpersand's workarounds.
Subject: 0001--Update-SawAmpersand.pm-docs-for-Perl-5.10-s-p.patch
From 1224921649b2aa9c701049b4bc0a3a4fd15545ee Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Andreas=20K=C3=B6nig?= <andk@cpan.org> Date: Wed, 16 Jun 2010 17:00:32 -0700 Subject: [PATCH] * Update SawAmpersand.pm docs for Perl 5.10's /p --- lib/Devel/SawAmpersand.pm | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/Devel/SawAmpersand.pm b/lib/Devel/SawAmpersand.pm index 9f37b55..100c862 100644 --- a/lib/Devel/SawAmpersand.pm +++ b/lib/Devel/SawAmpersand.pm @@ -56,7 +56,7 @@ There are at least three impacts for developers: =item * -never use $& and friends in a library. +never use $& and friends in a library. Use /p if you have perl 5.10 or later. =item * @@ -72,9 +72,19 @@ if PL_sawampersand is set by any of the modules you use or require. =back -=head2 Workaround +=head2 Workarounds -Fortunately perl offers easy to use alternatives, that is +Fortunately, perl offers easy to use alternatives. If you have perl 5.10 +or later, you can use the /p match operator flag to turn on per-match +variables that do the same thing: + + instead of this you can use this + + $` of /pattern/ ${^PREMATCH} of /pattern/p + $& of /pattern/ ${^MATCH} of /pattern/p + $' of /pattern/ ${^POSTMATCH} of /pattern/p + +If you are using an older perl, you can use these workarounds: instead of this you can use this @@ -87,18 +97,6 @@ $& and $+ for $' ($+ is not dependent on the number of parens in the original pattern). Note that the C</s> switch can alter the meaning of C<.> in your pattern. -=head2 Future Directions - - From: jmm@elegant.com (John Macdonald) - Date: Wed, 24 Dec 1997 10:49:56 -0500 - -How about adding an option to matches/substitutes that explicitly sets -$`, $&, and $'? When this new option is seen, PL_sawampersand will be -set for the duration of the match and then turned off. That causes the -expense for unflagged matches to go back to normal and only flagged -matches incur the extra expense and they would be the ones that -actually need it. (Or does PL_sawampersand need to affect the -compilation of the RE's too?) =head1 AUTHOR -- 1.6.2.5
Subject: Re: [rt.cpan.org #58468] Update SawAmpersand docs for Perl 5.10's /p variables
Date: Fri, 18 Jun 2010 07:51:57 +0200
To: bug-Devel-SawAmpersand [...] rt.cpan.org
From: andreas.koenig.7os6VVqR [...] franz.ak.mind.de (Andreas J. Koenig)
Show quoted text
>>>>> On Wed, 16 Jun 2010 20:04:21 -0400, "brian d foy via RT" <bug-Devel-SawAmpersand@rt.cpan.org> said:
Show quoted text
> I added some docs to SawAmpersand's workarounds.
Thank you! Patch applied and 0.32 released. -- andreas