Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: CSV_XS issue

by Tux (Abbot)
on Apr 07, 2013 at 10:04 UTC ( #1027351=note: print w/replies, xml ) Need Help??


in reply to CSV_XS issue

What Corion said:

$csv = Text::CSV_XS->new ({ binary => 1, eol => "\n", auto_diag => 1 } +);

The eol attribute is only required on output. The fact that it doesn't default to $/ is because of backward compatibility. It was the way it is when I took over.


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: CSV_XS issue
by anaconda_wly (Scribe) on Apr 08, 2013 at 03:17 UTC
    yes, it works, thanks you both! Good to know for the history!

      Just to add a bit to clarify and keep history, as Corion asked me in /msg: the $csv object is used for both input/getline/parse and output/print/combine. Most of the questions I get are for parsing, and most of my own scripts are parsing CSV data.

      The parsing code works better when not setting eol, as it then allows more "default" values (to be mixed) and works faster (but probably not measurable).

      Setting eol to $/ by default would most likely break a lot of parser scripts. Setting eol to $/ on output only makes some sense, but also makes the documentation harder and I wonder if it would be worth breaking backward compatibility.

      What does make sense in breaking backward compatibility is to make binary default to a true value, as I can't think of a modern situation where it would break a parser.


      Enjoy, Have FUN! H.Merijn
      cc

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027351]
help
Chatterbox?
[atcroft]: stevieb: Sad to say that I only recently learned that particular trick, but I have since found it very useful.... :)
[james28909]: ill be back with a solution eventually
[stevieb]: it's a reminder to re-inforce it :P
[atcroft]: james28909: That particular questions was a bit of trick, actually (depending on the country you are in). More interesting is, if you are trying to subtract from an epoch time, for instance, you might have to consider when/if DST occurs for a location,
[atcroft]: because you may have to adjust the number of seconds you change from an epoch from 86400 (not to mention leap seconds)....
[atcroft]: james28909: Although if your program is using a database, you might be able to "pass the buck" to the database and ask it to do the date change for you....

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-04-29 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.