|go ahead... be a heretic|
What is the difference between s/ and tr/by abhishes (Friar)
|on Apr 15, 2003 at 14:54 UTC||Need Help??|
abhishes has asked for the wisdom of the Perl Monks concerning the following question:
Hello Perl monks,
I wrote the following code
It produced the wrong results "The quick<<brown fox<<jumped<<over the<<lazy<<dog"
I removed the tr/ statement and inserted the following code $a =~ s/\n\n/\<br\/\>/g;
and the program gave me the right results "The quick<br/>brown fox<br/>jumped<br/>over the<br/>lazy<br/>dog"
But I can't understand why did the tr/ didn't work and why s/ did? what is the differnce between them. I used to think that they are two ways of doing the same thing.
thanks for your help.regards,