Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How to remove double quotes?

by andreychek (Parson)
on Jun 05, 2001 at 20:50 UTC ( #85879=note: print w/ replies, xml ) Need Help??


in reply to How to remove double quotes?

If I'm correct in what it is you are looking for, you could just do this:

my $string = qq{"Hello there"}; $string =~ s/"/'/g;
That uses a simple regular expression to change every double quote to a single quote.
You could, instead of a single quote, replace it with any character you like. HTH
-Eric

Update
Ack, apparently, you have to type pretty fast or else 5 people get their answers in before you do ;-)
Would anyone care to share why perl can do tr/"/'/ faster than s/"/'/?


Comment on Re: How to remove double quotes?
Download Code
(bbfu) (tr/// vs s///) Re(2): How to remove double quotes?
by bbfu (Curate) on Jun 05, 2001 at 22:25 UTC
      Would anyone care to share why perl can do tr/"/'/ faster than s/"/'/?

    Because s/// has to be able to handle all RE syntax and specialness while tr/// just considers its input to (mostly) be a simple character class. Much easier to deal with and, thus, much faster.

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-08-01 07:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls