[Wellington-pm] Side effects

michael@diaspora.gen.nz michael at diaspora.gen.nz
Fri Mar 31 02:22:40 PST 2006

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.

More information about the Wellington-pm mailing list