
KevinR
Veteran

Jan 17, 2005, 11:08 PM
Post #2 of 4
(1863 views)
|
|
Re: [inlimbo] remove whitespace
[In reply to]
|
Can't Post
|
|
lets look at what you have: The quick brown fox jumped over the lazy dog with the hidden characters exposed it can be simulated like this: The\squick\sbrown\n fox\sjumped\sover\n the\slazy\n dog" \s is a space \n is a newline what you want to do is replace the newlines with a space, which can be done like this: $line =~ s/\n/\s/g; The "g" option tells perl to replace all occurances of the pattern in the string. if its a windows file you may need to use: $line =~ s/\r\n/\s/g; or to cover both Unix and Windows style newlines: $line =~ s/\r?\n/\s/g; -------------------------------------------------
(This post was edited by KevinR on Jan 17, 2005, 11:10 PM)
|