in reply to Re: Substitution problem.
in thread Substitution problem.

Says fastolfe:
> tr/$from/$to/;
This won't work, because variables are not interpolated inside of tr///. Your line replaces $ with $; f with t; and r, o, and m with o.

Replies are listed 'Best First'.
Re: Re: Substitution problem.
by snax (Hermit) on Nov 25, 2000 at 19:50 UTC
    Indeed, so that one would want to use:
    eval("tr/$from/$to/");
    More and more the only place I end up using eval is in this type of construction.

      I hope neither $from or $to have a / in them...

      I actually use eval for quite a few things. For instance I may want to turn a template into code and then eval that. But for "quick-n-dirty" I don't reach for it with the obvious exception of the /e modifier for substitutions.

        Got me AGAIN. You are correct, sir. I'll never get all this perl stuff straight in my head!