making this a little more reliable
authorShawn Boyette <sboyette@esilibrary.com>
Wed, 15 Apr 2009 13:54:20 +0000 (13:54 +0000)
committerShawn Boyette <sboyette@esilibrary.com>
Wed, 15 Apr 2009 13:54:20 +0000 (13:54 +0000)
csv_ripper

index bf787ff..098d287 100755 (executable)
@@ -20,9 +20,10 @@ open CSV, '<', shift or die "Can't open file $!\n";
 
 while (<CSV>) {
     $csv->parse($_);
+    die "Bad data on line $.\n" if ($csv->error_diag);
     my @chunks = $csv->fields;
     my @out = ();
-    for (@ARGV)
-      { push @out, $chunks[$_]}
+    for my $chunk (@ARGV)
+      { push @out, $chunks[$chunk] }
     print join("\t", @out), "\n";
 }