First off, tr/// does not do interpolation, strings or regular expressions. For that you need s///g.
Your expression my $result = eval "tr/$search/$replace/"; is short for my $result = eval "\$_ =~ tr/$search/$replace/"; but it appears that there is nothing in $_. Perhaps you meant:
my $s = 'eabcde'; my $search = 'abcd'; my $replace = 'efgh'; eval "\$s =~ tr/$search/$replace/"; print "$search\n"; print "$replace\n"; print "$s\n";
In reply to Re: doing tr/// on-the-fly?
by jwkrahn
in thread doing tr/// on-the-fly?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |