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

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

Thread Previous | Thread Next
From:
Bram via RT
Date:
June 3, 2008 02:02
Subject:
[perl #54702] Feature: regexp modifier to disable interpolation like m''
Message ID:
rt-3.6.HEAD-11257-1212435458-287.54702-15-0@perl.org
On Fri May 23 03:01:21 2008, eda@waniasset.com wrote:
>
> Normally in m// and s/// the pattern is double-quote interpolated.
> You can avoid this by choosing '' as the delimiter.  But that's not
> always very readable (PBP for example recommends using only // and {}
> as delimiters).  And of course the pattern might contain ' 
characters.
> 
> 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;
> 
> where the /n modifier turns off interpolation.
 
I don't really like the idea of adding a modifier to supress 
interpolation...

Currently there is:
  $string =~ m/Pattern with a literal \$ sign/;  and
  $string =~ m'Pattern with a literal \$ sign';

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

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?

Also according to:
http://www.regular-expressions.info/refflavors.html  JGSoft and .NET 
are already using the  n  modifier for an explicit capture which can 
make it very confusing (for people coming from JGSoft and/or .NET) and/
or for regex tools.


Kind regards,

Bram

Thread Previous | 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