-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sumanth Sharma wrote:
| Can you help me figure out why need tr/// when you have s/// and
| Vice versa ( NO, s/// is more powerful?).

They don't do the same thing.  tr/// (or y///) is the *transliteration*
operator and can do things like replace an entire range of characters
with another range of characters:

~ y/a-d/0-3/;

replaces 'a' with '0', 'b' with '1', 'c' with '2', 'd' with '3'.

And for the operations tr/// can do that can also be done by by the s///
operator, tr/// has the advantage of (often[*]) being slightly faster.
You can use the Benchmark module to compare them.

You can read all about it in perldoc perlop.

Best regards,

Damon

[*] Academic caution ;)
- --

Damon Allen DAVISON
http://www.allolex.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAj0KqGrF7vyUoJCMRAijBAJ4isFRIRu7Ho5/2CWUKoIToZdAXzgCgsGeh
W669WHksrhQbaMuNqP4B4ow=
=UA7Y
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to