use strict; use warnings; use autodie; use Benchmark qw( cmpthese ); use Text::CSV_XS; my $file = "sample.csv"; my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 }); cmpthese (10, { regex => sub { open my $fh, "<", $file; while (<$fh>) { my @s = map {s/[",]//g;$_}(split /,(?!(?:[^",]+",))/,$_)[0,8]; } }, csv_xs => sub { open my $fh, "<", $file; while (my $row = $csv->getline ($fh)) { my @s = @{$row}[0,8]; } }, });