Skip to content

Instantly share code, notes, and snippets.

@mattak
Created May 23, 2013 05:34
Show Gist options
  • Save mattak/5632946 to your computer and use it in GitHub Desktop.
Save mattak/5632946 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.010;
use Text::CSV_XS;
use Log::Minimal;
use Path::Class;
my $csv = Text::CSV_XS->new({binary => 1}) or die 'cannot new Text::CSV_XS';
my $from_stdin = ($#ARGV != 0);
my $io = ($from_stdin) ? *ARGV : file($ARGV[0])->openr;
while (my $row = $csv->getline($io)) {
my @fields = @$row;
say join("\t", @fields);
}
$csv->eof or $csv->error_diag();
$io->close if ($from_stdin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment