[Wellington-pm] Side effects
Cliff Pratt
enkidu at cliffp.com
Mon Apr 3 01:06:28 PDT 2006
michael at diaspora.gen.nz wrote:
> Cliff Pratt writes:
>
>> my $v = "123456789ABC" ; my $v1 = "7" ;
>>
>> print "|" . eval { $v =~ s/$v1// ; return $v } . "|\n" ;
>
>
>> After trying various things I got the line of code I printed at the
>> beginning. Is this the best way of doing it? It seems pretty OK
>> to me!
>
>
> What's wrong with two separate statements?
>
> $v =~ s/$v1//; print "|$v|\n";
>
> I'd get confused as a maintenance programmer as to why the
> substitution had to be done in the middle of the print statement. --
> michael.
>
I don't know. It sort of seemed tidier to "set-it-and-use-it" rather
than "set it" and "use it".
Seeing as the two replies I received said roughly the same, I've dropped
back to "set it" and "use it"!
Cheers,
Cliff
--
http://barzoomian.blogspot.com
More information about the Wellington-pm
mailing list