Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
XP is just a number
 
PerlMonks  

Re^3: How to use perl to parsing a XML file to csv file which have the same sequence in xml file?

by tobyink (Abbot)
on Dec 30, 2012 at 19:38 UTC ( #1010959=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How to use perl to parsing a XML file to csv file which have the same sequence in xml file?
in thread How to use perl to parsing a XML file to csv file which have the same sequence in xml file?

It worked on my machine, but Text::CSV's behaviour can be a little variable - it has two underlying implementations: one in pure Perl, and a faster one in C. Which one you get is the luck of the draw. In this case, $row is a blessed arrayref; Text::CSV expects an arrayref; it looks like one of the implementations rejects the arrayref if it's blessed but the other does not.

$csv->print(\*STDOUT, [@$row]); # unblessed shallow clone of $row
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re^3: How to use perl to parsing a XML file to csv file which have the same sequence in xml file?
Select or Download Code
Re^4: How to use perl to parsing a XML file to csv file which have the same sequence in xml file?
by Anonymous Monk on Dec 31, 2012 at 03:48 UTC
    Hah, its the PP version that is too picky :)
    $ perl -MText::CSV_PP -e " Text::CSV_PP->new->print(\*STDOUT, [1..3] ) + " 1,2,3 $ perl -MText::CSV_XS -e " Text::CSV_XS->new->print(\*STDOUT, [1..3] ) + " 1,2,3 $ perl -MText::CSV_XS -e " Text::CSV_XS->new->print(\*STDOUT, bless[1. +.3],666 ) " 1,2,3 $ perl -MText::CSV_PP -e " Text::CSV_PP->new->print(\*STDOUT, bless[1. +.3],666 ) " Expected fields to be an array ref at -e line 1.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010959]
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: (14)
As of 2014-04-18 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (469 votes), past polls