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

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

Thread Previous
Father Chrysostomos via RT
August 21, 2012 16:46
[perl #54702] Feature: regexp modifier to disable interpolation like m''
Message ID:
On Tue Aug 21 16:05:52 2012, 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

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