in reply to doing tr/// on-the-fly?
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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: doing tr/// on-the-fly?
by toolic (Bishop) on Mar 18, 2010 at 01:27 UTC | |
by Anonymous Monk on Mar 18, 2010 at 01:37 UTC | |
by Anonymous Monk on Mar 18, 2010 at 13:33 UTC | |
by BrowserUk (Patriarch) on Mar 18, 2010 at 14:17 UTC | |
|
Re^2: doing tr/// on-the-fly?
by Anonymous Monk on Mar 18, 2010 at 01:26 UTC | |
by ikegami (Patriarch) on Mar 18, 2010 at 04:27 UTC | |
by Anonymous Monk on Mar 18, 2010 at 01:31 UTC | |
by jwkrahn (Abbot) on Mar 18, 2010 at 01:43 UTC |