Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: string manipulation

by indigo (Scribe)
on Mar 29, 2001 at 22:43 UTC ( #68160=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://68160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2020-10-24 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (242 votes). Check out past polls.

    Notices?