On Wed, 28 Apr 2004 10:42:01 +0530
"Sumanth Sharma" <[EMAIL PROTECTED]> wrote:

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

Well I would say that the way they operate is different.

tr/// looks at each character and replaces it

eg, tr/aeiou/-/ replaces all vowels with a -

s/// looks for a pattern and replaces that pattern

eg s/aeiou/-/ replace any pattern of aeiou with a -

Try this

#!/usr/bin/perl -w
use strict;

my $word='aeiou';
$word =~tr/aeiou/-/;
print "translated word is $word\n";

$word='aeiou';
$word =~s/aeiou/-/;
print "substituted word is $word\n";

====================================
translated word is -----
substituted word is -




Owen


-- 
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