in reply to Cannot work on second file after reading first file.
You're intentionally skipping the first line of your CSV, which is probably because it contains field names, and isn't useful to you. But there's nothing to test your assertion that the first line of the file will be field names, or that it even exists. You might change it to:
my $head = $csv->getline($fh); die "Empty CSV." unless defined $head; warn "Field names detected: (@{$head})\n" if $ENV{MYSCRIPT_DEBUG}; die "No more CSV rows to process after header.\n" if $csv->eof;
Set an environment variable named "MYSCRIPT_DEBUG" to a true value before running if you want debugging info (the warn statement). This will at least test the assertion that your CSV file is not empty, that it starts out with field names, and that there are additional rows available to process after the header row.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Cannot work on second file after reading first file.
by 1straw (Novice) on Feb 28, 2014 at 16:43 UTC | |
by davido (Cardinal) on Feb 28, 2014 at 16:48 UTC | |
by 1straw (Novice) on Feb 28, 2014 at 17:06 UTC | |
by davido (Cardinal) on Feb 28, 2014 at 17:16 UTC |