#!/usr/bin/perl # TODO # # * add getopt support # * use tag generator to expand list of wanted fields? # * insertion of constant-value fields # * field mapping ("some text" -> 4)? # csv-extractor FILENAME FIELD_LIST use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new( {binary => 1}); open CSV, '<', shift or die "Can't open file $!\n"; while () { $csv->parse($_); die "Bad data on line $.\n$_\n" if ($csv->error_diag); my @chunks = $csv->fields; my @out = (); for my $chunk (@ARGV) { push @out, $chunks[$chunk] } print join("\t", @out), "\n"; }