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

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

Thread Previous | Thread Next
Bram via RT
June 3, 2008 02:02
[perl #54702] Feature: regexp modifier to disable interpolation like m''
Message ID:
On Fri May 23 03:01:21 2008, 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 ' 
> 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 

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:  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,


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About