As I said, the problem was probably me and not Text::CSV_XS. But so as not to be elusive I'll fill you in as to why I gave up on it.
Firstly I was working on something that had to done as fast as humanly (or inhumanly as the case sometimes is) possible, so when I encountered the problems with Text::CSV_XS I didn't spend too much time on figuring out what wrong.
I wasn't doing anything particularly fancy or neat, just formatting some data from a TDF. But for some reason it would only find 4 of 9 records, and I can't see why. There wasn't anything too gruesome in the data (as it was created to be as friendly as possible) and splitting it on "\t" seemed to work a treat so I stuck with that.
If you're interested in the code it was something like this -
use strict;
use Text::CSV_XS;
my $tdf = Text::CSV_XS->new({'sep_char'=>"\t"});
open(TDF, "somedata.tdf") or die("b0rk - $!");
my @fields = ();
while($tdf->parse(scalar <TDF>)) {
@fields = $tdf->fields();
print "@fields\n";
}
That seems to work fine on some simple data, but it broke on the data I was feeding it, so I'm guessing that the data was the root of the problem (and I would've dug further but I was under a *wee* bit of pressure ;o). I should imagine I'll use it if the need ever arises again, and hopefully the data behaves itself this time (assuming it was the data ...)
HTH
broquaint
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|