Cory Petkovsek wrote:

> How can I use a variable as a search or replace selection using tr//?
> 
> $_ = "be!happy";
> $before="!";
> $after=" ";
> tr/$before/$after/;
> print $_;

Consider using s/// instead of tr///.

        s/$before/$after/g;

If $before and $after are more than one character, you can
use eval.

        eval "tr/$before/$after/";



-- 
Bob Miller                              K<bob>
kbobsoft software consulting
http://kbobsoft.com                     [EMAIL PROTECTED]

Reply via email to