http://www.perlmonks.org?node_id=250581

abhishes has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl monks,
I wrote the following code
my $a = "The quick brown fox jumped over the lazy dog"; $a =~ tr/\n\n/\<br\/\>/; print "$a\n";

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,
Abhishek.