Try:
eval "\$test =~ y/$x/$y/;";
Perfect.
Thanks,
John
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 10-11-29 11:51 PM, John wrote:
I tried using that, but $test wasn't changed here:
$test = "This is a test.";
$x = "is";
$y = "si";
eval $test =~ y/$x/$y/;
print "$test\n";
Try:
eval "\$test =~ y/$x/$y/;";
--
Just my 0.0002 million dollars worth,
Shawn
P
Is there a way to use variables in a translation? I'm looking for a way
to use, for example, $x = "abc" and $y = "ABC" so something like
y/$x/$y/;
behave like
y/[abc]/[ABC]/;
The tr/// operator doesn't interpolate so you have to do something like:
eval y/$x/$y/;
I tried using that, but $t
> "JWK" == John W Krahn writes:
JWK> John W. Krahn wrote:
>> John wrote:
>>> Is there a way to use variables in a translation? I'm looking for a way
>>> to use, for example, $x = "abc" and $y = "ABC" so something like
>>
>> eval y/$x/$y/;
JWK> Oops!
you forgot to oops that li
John W. Krahn wrote:
John wrote:
Is there a way to use variables in a translation? I'm looking for a way
to use, for example, $x = "abc" and $y = "ABC" so something like
y/$x/$y/;
behave like
y/[abc]/[ABC]/;
The tr/// operator doesn't interpolate so you have to do something like:
eval y/$x
John wrote:
Is there a way to use variables in a translation? I'm looking for a way
to use, for example, $x = "abc" and $y = "ABC" so something like
y/$x/$y/;
behave like
y/[abc]/[ABC]/;
The tr/// operator doesn't interpolate so you have to do something like:
eval y/$x/$y/;
Or perhaps:
m
Is there a way to use variables in a translation? I'm looking for a way
to use, for example, $x = "abc" and $y = "ABC" so something like
y/$x/$y/;
behave like
y/[abc]/[ABC]/;
Thanks,
John
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-