in reply to string manipulation

($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.

Replies are listed 'Best First'.
Re: Re: string manipulation
by indapa (Monk) on Mar 30, 2001 at 00:59 UTC
    Ch. 15 in Learning Perl also gives a good explaination of transliteration.