in reply to Unique with Text::CSV_XS

my %seen; while (my $row = $csv->getline ($fh)) { # WTF do you think chomp is doing here? $seen{pack "ll", $row->[1], $row->[9]}++ and next; # change ll to +reflect types # continue processing ... }

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: Unique with Text::CSV_XS
by Anonymous Monk on Jan 08, 2010 at 22:15 UTC

    For the OP's benefit, I'll make this explicit:

    chomp; basically removes from $_ a terminating string equivalent to $\; chomp $foo; does the same, but to $foo rather than $_. See perldoc -f chomp.

    However, you have no use for chomp here. You're getting "rows" of data which has been parsed for you and are now hashrefs, not strings!

      Just for the record, $row is an arraref, not a hashref.

      $ echo 1,a | perl -MDP -MText::CSV_XS -wle'DPeek(Text::CSV_XS->new->ge +tline(*ARGV))' \AV() $ echo 1,a | perl -MDP -MText::CSV_XS -we'DDumper(Text::CSV_XS->new->g +etline(*ARGV))' $VAR1 = [ '1', 'a' ];

      Enjoy, Have FUN! H.Merijn