0

Using tr command I want to convert Hello into Hii. My command was:

$_="Hello";
print;
tr/Hello/Hi/;
print;

But the result was Hiiii. What did I do wrong? What is the right way to do it?

2

To replace Helloby Hii you could use:

s/Hello/Hii/

tr works different. Using tr both character sequences are handled as lists. The first character of the first list is replaced by the first character of the second list. So, H is replaced by H, e is replaced by i and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.