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

Re: Reading a text file collapsing line continuations

by repellent (Priest)
on Mar 09, 2009 at 17:53 UTC ( #749369=note: print w/ replies, xml ) Need Help??


in reply to Reading a text file collapsing line continuations

If all you care about is printing it out, you don't have to accumulate the lines before printing. Just print out the partial lines (without line endings).

If the input to your existing code may be broken up in multiple lines via backslash \, just filter the input first before it gets sucked in by your existing code:

perl -pe 's=\s*\\\s*$/= ='


Comment on Re: Reading a text file collapsing line continuations
Select or Download Code
Re^2: Reading a text file collapsing line continuations
by skx (Parson) on Mar 09, 2009 at 17:57 UTC

    Thanks for the suggestion - in my case I actually want to parse & process the lines. This example only prints them out to make a complete program which demonstrates the problem.

    Steve
    --
      I usually decouple the code that joins lines from the actual program which parses the lines. Hence, the program makes the assumption that lines are not broken, and thus, is able to concentrate on its sole purpose.

      This works out cleaner for me because I find that many programs require that lines be joined in the same way. Rather than duplicating code in many programs, I place the join-lines filter up front. It's also easier if the programs read from STDIN, so filters could be piped along in the *NIX environment.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-12-26 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls