[tpm] how to resubstitute a captured value

Richard Dice rdice at pobox.com
Fri Apr 19 09:08:19 PDT 2013


It's not just s///ee.  It's as many e's as you want / need, though of
course with more e's that way lies madness...

I remember people talking about Lenzo using 5 e's in a s///eeeee when I was
at YAPC 19100, though some people when they told they story said it was
only 4.  Ahh, apocrypha... :-)

Cheers,
 - Richard



On Fri, Apr 19, 2013 at 12:02 PM, Dave Doyle <dave.s.doyle at gmail.com> wrote:

> didn't know about the s///ee trick though. I had done this:
>
> #!/usr/bin/perl
>
> use strict;
>
> my $match = '^-?(.+?):?$';
> my $replace = '"-$1:"';
>
>
> while (my $line = <DATA>) {
> $line =~ s/$match/eval $replace/e;
> print $line;
> }
>
> __DATA__
> stuff
> -stuff
> stuff:
> -stuff:
>
>
> --
> dave.s.doyle at gmail.com
>
>
> On 19 April 2013 11:59, Dave Doyle <dave.s.doyle at gmail.com> wrote:
>
>> Hah. Was just about to do the same.
>>
>> --
>> dave.s.doyle at gmail.com
>>
>>
>> On 19 April 2013 11:58, Mike Stok <mike at stok.ca> wrote:
>>
>>> If I was feeling crazy
>>>
>>> #!/usr/bin/perl
>>> use strict;
>>> my $match = '^-?(.+?):?$';
>>> my $replace = '"-$1:"'; # note the quotes...
>>>
>>> while (my $line = <DATA>) {
>>>     $line =~ s/$match/$replace/ee;
>>>     print $line;
>>> }
>>> __DATA__
>>> stuff
>>> -stuff
>>> stuff:
>>> -stuff:
>>>
>>>
>>> On 2013-04-19, at 11:16 AM, Fulko Hew <fulko.hew at gmail.com> wrote:
>>>
>>> #!/usr/bin/perl
>>> use strict;
>>> my $match = '^-?(.+?):?$';
>>> my $replace = '-$1:';
>>>
>>> while (my $line = <DATA>) {
>>>     $line =~ s/$match/$replace/;
>>>     print $line;
>>> }
>>> __DATA__
>>> stuff
>>> -stuff
>>> stuff:
>>> -stuff:
>>>
>>>
>>> --
>>>
>>> Mike Stok <mike at stok.ca>
>>> http://www.stok.ca/~mike/
>>>
>>> The "`Stok' disclaimers" apply.
>>>
>>>
>>>
>>>
>>>
>>
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20130419/76436714/attachment-0001.html>


More information about the toronto-pm mailing list