|
|
| laziness, impatience, and hubris | |
| PerlMonks |
Re: Expected fields to be an array refby armstd (Friar) |
| on Oct 11, 2011 at 04:10 UTC ( #930738=note: print w/ replies, xml ) | Need Help?? |
|
Not knowing Text::CSV_XS other than browsing the perldoc real quick, I can mainly only comment on your code. The main thing I see is mixing lists and ARRAYrefs, and lots of expensive copying back and forth between the two. Here's the first problem:
You are constructing $file2{$id} as an ARRAYref with [] (correctly). But you're not dereferencing it on access. Why add the "" at the beginning of the list? You're probably looking for something more like:
Next, this is likely not what you expect:
You've got a string consisting of three ARRAYrefs joined by tabs. So that does match the errors you're seeing. It's probably looking for something simpler, a single reference to a list with all the data in it. Probably looking for something more like:
Last, you need more error checking imo. Ultimately, I would recommend taking it a step further and just use references throughout, rather than copying lists to refs and back. It's just not necessary, and it causes your syntax to have to switch back and forth as well. References will keep your syntax consistent. There are lots of other ways to optimize this pretty significantly, but I'll leave that to you. --Dave
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||