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

Replies are listed 'Best First'.
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.