Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Strip line feeds from file

by cbro (Pilgrim)
on Jun 09, 2003 at 20:20 UTC ( #264451=note: print w/ replies, xml ) Need Help??


in reply to Strip line feeds from file

Make a perl script (yourscript.pl) that contains the line:

s/[\n\r\f]//g
Then run:
perl -i.tmp -p yourscript.pl file.txt
against your file...say file.txt.
That is how you edit a file in-place. You will have your old file as file.txt.tmp to do a comparison and confirm it worked if you want.
You could also do this for each line if you read the file into an array.
That is...
open (F,"file.txt"); @ar = <F>; close(F); foreach (@ar) { s/[\n\r\f]//g; # do what you want with the line. }

Update:
Well, it seems I was a little slow on the typing, other than the other posts do not contain the '\f'. You may have wanted to include this as a reply on your last post cuz now that one is going to get unneeded attention.


Comment on Re: Strip line feeds from file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (19)
As of 2015-07-02 17:08 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 (44 votes), past polls