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?

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .