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

Re: Printing to file from Text::CSV_XS

by hippo (Bishop)
on Jan 28, 2016 at 16:58 UTC ( [id://1153897]=note: print w/replies, xml ) Need Help??


in reply to Printing to file from Text::CSV_XS

If you specify an appropriate eol value in the constructor it should use that. eg. for Unix style line endings:

my $csv = Text::CSV_XS->new({ sep_char => "\t", eol => "\n" });

Update: The documentation is actually very clear on this:

When not passed in a generating instance, records are not terminated at all, so it is probably wise to pass something you expect. A safe choice for eol on output is either $/ or \r\n

Replies are listed 'Best First'.
Re^2: Printing to file from Text::CSV_XS
by dorko (Prior) on Jan 28, 2016 at 19:46 UTC
Re^2: Printing to file from Text::CSV_XS
by edimusrex (Monk) on Jan 28, 2016 at 17:03 UTC

    That did work for the line issue yet it is still wrapping the entire line in quotes

      Your subroutine cleanthis joins all the fields into one. Return a list instead and let Text::CSV_XS handle the joining.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

        ah, I knew it was probably something simple. Thank you

        Changing return join("\t",@formatted) to simply return (@formatted) did the trick

      That's because your pre-processing is only passing a single field to the print method. If you don't want the quotes, don't use them. See quote_char.

      I do encourage you to read the documentation. It's very comprehensive.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-26 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found