Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: Reading Multiple lines

by blazar (Canon)
on Oct 18, 2008 at 10:16 UTC ( #717924=note: print w/replies, xml ) Need Help??

in reply to Re: Reading Multiple lines
in thread Reading Multiple lines

I think that Text::CSV has a solution for that, you might need to tweak some of the options though.

I personally believe that if nothing else for completeness one should mention Text::xSV as well. In particular, before posting I checked its docs and it says:

People usually naively solve this with split. A next step up is to read a line and parse it. Unfortunately this choice of interface (which is made by Text::CSV on CPAN) makes it difficult to handle returns embedded in a field. (Earlier versions of this document claimed impossible. That is false. But the calling code has to supply the logic to add lines until you have a valid row. To the extent that you don't do this consistently, your code will be buggy.) Therefore you it is good for the parsing logic to have access to the whole file. This module solves the problem by creating a CSV object with access to the filehandle, if in parsing it notices that a new line is needed, it can read at will.

The additional emphasis is mine: what is claimed there means that the module should solve the OP's problem. Apologies both to you and the OP for replying so late...

If you can't understand the incipit, then please check the IPB Campaign.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://717924]
[Corion]: I found plenty of not chatty enough logs with Perl too ... I'm slowly coming to appreciate Log::Log4perl resp. our homegrown alternative
[tye]: my experience with python so far is more like finding a moderately useful error message is a shocking surprise.
Corion disappears
[tye]: I get an error string but no reason and no context. Like die "Could not read file.\n" but with a stack trace where all of the useful context is stripped.
[thezip]: Heya tye!
[tye]: hey, thezip!

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2017-09-21 20:18 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (252 votes). Check out past polls.