in reply to Text::CSV_XS and line-endings
--roboticus#!/usr/bin/perl -w use strict; use Text::CSV_XS; # Slurp up the whole file open(INF,"<test.mac") || die "Can't open test.mac!"; my $file = <INF>; close(INF); # Convert CRs to LFs $file =~ s/\015/\012/g; # Parse CSV file line-by-line my $csv = Text::CSV_XS->new(); for my $i (split /\012+/, $file) { my $status = $csv->parse($i); print "ST:", $status; for my $j ($csv->fields) { print " [", $j, "]"; } print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Text::CSV_XS and line-endings
by jdalbec (Deacon) on Mar 17, 2006 at 03:45 UTC | |
by snowhare (Friar) on Mar 17, 2006 at 12:32 UTC | |
|
Re^2: Text::CSV_XS and line-endings
by samtregar (Abbot) on Mar 17, 2006 at 16:19 UTC |