#!/pro/bin/perl

use strict;
use warnings;
use autodie;

use IO::File;
use Text::CSV_XS;
use Benchmark "cmpthese";

my $filename = $ARGV[0];
$filename && -f $filename or die ("Please pass the filename on the command line.\n");

cmpthese (5, {
    tjc	=> \&tjc,
    tux => \&tux,
    });

sub tjc
{
    my $csv = Text::CSV_XS->new;
    my $fh  = IO::File->new ("<$filename");

    my $header = $csv->getline ($fh);
    # $csv->column_names(@$header);

    while (not $csv->eof) {
	my $cols = $csv->getline ($fh);
	next unless $cols;
	}

    $fh->close;
    }

sub tux
{
    my $csv = Text::CSV_XS->new ({ binary => 1 });
    open my $fh, "<", $filename;

    my %rec;
    $csv->bind_columns (\@rec{@{$csv->getline ($fh)}});
    while ($csv->getline ($fh)) {
	# ...
	}

    close $fh;
    }
