use Text::ParseWords; @fields = (); my $file = $ARGV[0] or die "Missing CSV file on the command line\n"; open($text, '<', $file) or die "Could not open '$file' $!\n"; $line = <$text>; @fields = quotewords(',', 0, $line); foreach $field (0..$#fields) { print $field + 1 . " $fields[$field]\n"; } #### my $file = $ARGV[0] or die "Missing CSV file on the command line\n"; open($text, '<', $file) or die "Could not open '$file' $!\n"; while ($line = <$text>) { @fields = quotewords(',', 0, $line); } foreach $field (0..$#fields) { print $field + 1 . " $fields[$field]\n"; }