Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: replace middle spaces with commas

by Anonyrnous Monk (Hermit)
on Feb 02, 2011 at 04:56 UTC ( #885663=note: print w/ replies, xml ) Need Help??


in reply to replace middle spaces and write to another file

I want commas in middle spaces not at the end, but here I got commas at the end also...

AFAICT, your problem arises from using \s in the substitution s/\s/,/g, instead of a plain space character, i.e. s/ /,/g.

\s stands for "whitespace", which includes newline (\n), so the newlines are turned into commas, too.


Comment on Re: replace middle spaces with commas
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2015-07-04 11:13 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 (59 votes), past polls