in reply to Reading a CSV file

Yeah, there are a few things you might consider changing, here. Each program should start with
use strict;
in addition to use warnings;. Once you do that, though, you'll need the lines:
my $read; my @lst;
I noticed a couple minor things about your 'open'. You probably shouldn't put IN in parens and you'll be a little safer if you use the 3 parameter version. The other advice, to use 'or die' is necessary, here:
open (IN, "<", "dev.csv") or die "couldn't open 'dev.csv': $!\n";
After you get this working, though, you'll stumble across a subtle bug in your 'while' loop. By putting $read in parens, you've made it an element of a list. <IN> in a list context will slurp-up the whole file and, since there's only one element of the list ($read), only the first line gets assigned to something -- the rest of the file gets discarded. This way, the 'while' is guaranteed to run exactly once. Instead, you probably want:
while (my $read=<IN>) { print "3\n"; chomp ($read); #... }
Hope this helps!
--
Wade

Replies are listed 'Best First'.
Re^2: Reading a CSV file
by alchang (Novice) on Mar 31, 2008 at 14:50 UTC
    Thanks for the advice, I'm still pretty new to Perl as you can see :(.