in reply to Parsing a text file
On my machine it told me it found data on 1 line, which is what I would expect...
neither elsif (/^M/) nor split /^M/ are doing what you expect. If you want cntrl-M you want \cM not ^M -- though I'd use \x0D, but that's a matter of taste.
especially because something odd is apparently happening, I'd recommend an or die "failed to open $csv: $!" after the open.
you don't really need the for loop, you could simply push @chunks, split(/\cM/, $_). Note that split throws away trailing separators, so if a line ends "\cM\cM\cM" you won't end up with three blank lines -- which may or may not be what you want.
you pass the filename $csv to the read_csv subroutine, but don't use it, which doesn't look right.
But I cannot explain why you seem to get 0 lines... I don't suppose it's possible that you have set $/ to undef ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing a text file
by calmthestorm (Acolyte) on Jan 14, 2009 at 00:53 UTC | |
by gone2015 (Deacon) on Jan 14, 2009 at 08:56 UTC |