Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: string manipulation

by indigo (Scribe)
on Mar 29, 2001 at 22:43 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://68160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-25 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found