develooper Front page | perl.perl5.porters | Postings from June 2008

RE: [perl #54702] Feature: regexp modifier to disable interpolation like m''

Thread Next
From:
Ed Avis
Date:
June 3, 2008 09:09
Subject:
RE: [perl #54702] Feature: regexp modifier to disable interpolation like m''
Message ID:
1EC0234F7B1CA34BA1E99F48A817A1BDC2801D@wcl-exc.wcl.local
>>As an alternative to m'', how about a pattern modifier /n to 
>>suppress interpolation?
>> 
>>Old style: $string =~ m'Pattern with a literal $ sign';
>> 
>>Proposed new style: $string =~ /Pattern with a literal $ sign/n;

>Personally, I have never ever used m'' and I don't see a 
>reason to use / n over \.

m'' is used rarely but when you need it, it's most handy.  The classic example is matching an RCS version string like $Id: xxx$ or $Revision: xxx$.  I recognize that some people will prefer to use backslashes.

>A reason against it:
>You need to look at the end of the regex to know wheter or not 
>things get interolated. What if the regex is using the /x 
>modifiers and takes 10 lines?

I think /x is exactly the precedent in favour.  You have to look to the end of the regex to see if it has /x making comments and whitespace insignificant.  This doesn't seem to be a problem in practice.

>Also according to:
>http://www.regular-expressions.info/refflavors.html  JGSoft 
>and .NET are already using the  n  modifier for an explicit 
>capture

The exact letter isn't important, it could be /d or whatever.

(BTW, is it possible to post bug followups directly in the web interface?)

-- 
Ed Avis <eda@waniasset.com>

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About