develooper Front page | perl.perl5.porters | Postings from August 2012

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

Thread Previous
From:
Father Chrysostomos via RT
Date:
August 21, 2012 16:46
Subject:
[perl #54702] Feature: regexp modifier to disable interpolation like m''
Message ID:
rt-3.6.HEAD-11172-1345592774-1194.54702-15-0@perl.org
On Tue Aug 21 16:05:52 2012, eda@waniasset.com wrote:
> I feel that a way to avoid double-quote interpolation in regexps is
>    sometimes needed (for progranner sanity) but I can accept that
>    stuffing more options into the already complex regexp syntax may
>    not be the way.  I would be happy to have a programmatic way to
>    drive the regexp engine without special syntax:
> 
>     my $subst = new Regexp::Subst(qr/a+/, 'b');
>     my $in = 'xaa';
>     say $subst->($in); # prints xb
> 
> Then most of the quoting problems go away.  A mechanism for compiling
>    regexps from strings without qr// syntax would also be welcome.  Or
>    is there already a well-known module to do this stuff?

What I normally do is $foo = "hairy $string with ^lots^ and *lots* of
metachars."; s/\Q$foo//.

Why isn’t \Q sufficient for your purposes?

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: rejected
https://rt.perl.org:443/rt3/Ticket/Display.html?id=54702

Thread Previous


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