Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: append line to previous line in txt file

by prasadbabu (Prior)
on Jul 09, 2008 at 05:36 UTC ( #696383=note: print w/ replies, xml ) Need Help??


in reply to append line to previous line in txt file

Hi mmittiga17,

If I understood your requirement correctly, you can do it in the below method, iff your file size is not huge.

use strict; use warnings; my $file = do {local $/, <DATA>}; #read the file from <DATA> $file =~ s/\n\;/\;/g; #replace newline followed by semicolon with semi +colon print $file; output: -------- asdfadfasdf asfadfasdf;asfadfasdfas fasfasdfas;asdfasdfasd asdfasdfasfd __DATA__ asdfadfasdf asfadfasdf ;asfadfasdfas fasfasdfas ;asdfasdfasd asdfasdfasfd

Prasad


Comment on Re: append line to previous line in txt file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2015-07-04 04:27 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 (57 votes), past polls