[Wellington-pm] Side effects

Cliff Pratt enkidu at cliffp.com
Thu Mar 30 23:45:49 PST 2006


Hi Perlmongers!

I don't know if this qualifies as a tip or a question!

my $v = "123456789ABC" ;
my $v1 = "7" ;

print "|" . eval { $v =~ s/$v1// ; return $v } . "|\n" ;

Now, orginally, I had the following:

print "|" . $v =~ s/$v1// . "|\n" ;

which prints "1", since "$v =~ s/$v1//" returns '1'.

I wanted to print the side-effect ($v with "7" removed).

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!

Cheers,

Cliff

-- 

http://barzoomian.blogspot.com


More information about the Wellington-pm mailing list