Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: string manipulationby indigo (Scribe) |
on Mar 29, 2001 at 22:43 UTC ( [id://68160]=note: print w/replies, xml ) | Need Help?? |
($outstring = $instring) =~ tr/-/_/;
This might be a little better. The tr (translate) operator does exactly what you are asking for. man perlop for more info. Also, in Perl, strings and arrays are not interchangible. $string[2] does not get you the third letter of $string...it gets you the third element of the array @string, a different beast entirely.
In Section
Seekers of Perl Wisdom
|
|