Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: What is wrong here (Replacing Strin pieces)

by Laurent_R (Monsignor)
on Jul 16, 2013 at 11:54 UTC ( #1044569=note: print w/ replies, xml ) Need Help??


in reply to What is wrong here (Replacing Strin pieces)

Do you want to replace all the dashes, or only those at the beginning and at the end of the string?

For replacing all dashes, the tr/// function will be better (and much faster).

In the other case (only the dashes at the beginning and at the end), then you'll need to count the number of dashes you will be removing to figure out how many questions marks to insert, which can be done in several different ways (remember that s/// returns the number of substitutions performed), but none of those I can think of in the moment is really elegant.


Comment on Re: What is wrong here (Replacing Strin pieces)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2015-07-28 19:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls