sobering observation, python vs. perl

BartC bc at freeuk.com
Thu Mar 17 15:06:17 EDT 2016


On 17/03/2016 18:53, Marko Rauhamaa wrote:
> BartC <bc at freeuk.com>:

>> sub replacewith{
>>     $s = $_[0];
>>     $t = $_[1];
>>     $u = $_[2];
>>     $s =~ s/$t/$u/;
>>     return $s;
>> }
>>
>> Although once done, the original task now looks a proper language:
>>
>> print (replacewith("I have a dream","have","had"));
>
> Now try your function with:
>
>     print (replacewith("I have a dream",".","had"));

Yeah, it needs your quotemeta line (whatever that does). But the call is 
unaffected as the clutter is in the function.

-- 
bartc




More information about the Python-list mailing list