in reply to Reading a CSV file

alchang,
Welcome. It is very likely your file is never being opened for reading but you are not checking the return code.
use strict; use warnings; open(my $fh, '<', 'dev.csv') or die "Unable to open 'dev.csv' for read +ing: $!"; while (<$fh>) { print; }
See what the above code does for you. Also, if you are handling CSV, I would recommend using Text::CSV which recently got a major overhaul.

Cheers - L~R

Replies are listed 'Best First'.
Re^2: Reading a CSV file
by alchang (Novice) on Mar 31, 2008 at 14:25 UTC
    Thanks for your response. I copied and pasted your code but there still was no output. I'll try to obtain Text::CSV and see if that works.
      alchang ,
      If there was no output at all, then you likely have an empty file. That code should have done 1 of 2 things:
      1. Generated an error because you were unable to open the file 2. Printed every line in the file
      Since it did neither, I must assume that the file exists, you can open it, but that it is empty. Using a module will not change that. I recommended it because CSV can be tricky but you aren't yet at the tricky part.

      Update: Since you have said elsewhere in the thread that the file is 63MB - consider that you may have two files with the same name in different directories. Since you have not told perl to open a file with an absolute path, it is looking for a file in the same directory that you executed perl from.

      Cheers - L~R

        I think i gave Perl a path to find the file but there is still no output. To be sure I did the right thing here's what I changed:
        open(my $fh, '<', 'C:\bio stuff\Aubrey\'s project\dev.csv') or die "Un +able to open 'dev.csv' for read
        Is that what you meant?