[Chicago-talk] Why does Perl hate my csv file?

tiger peng tigerpeng2001 at yahoo.com
Thu Dec 13 20:15:35 PST 2007

It seems that your $x=<FILE> consumed the whole file.
Is there newline character "\n" in your 1.csv file?How did you invoke the script?  How did you change the file name? Is the size of file changed after you change the name?

----- Original Message ----
From: Eric Ellington <e.ellington at gmail.com>
To: Chicago.pm chatter <chicago-talk at pm.org>
Sent: Thursday, December 13, 2007 6:46:26 PM
Subject: [Chicago-talk] Why does Perl hate my csv file?

Using this script:

use strict;


sub main
    open(FILE,"1.csv") || die "COULD NOT OPEN FILE: \n$!\n";
    #nix header
    my $x = <FILE>;
    while (<FILE>)
        print $_;

where 1.csv contains:

I get no output.

Change the file name to 1.txt and I get output or if I comment out "my
$x = <FILE>;" and even then the output is jacked up. Why is that? Does
open do something special when it sees a file that ends in .csv? I
found nothing at http://perldoc.perl.org/functions/open.html or on
ActiveState's website.

This is perl, v5.8.8 built for MSWin32-x86-multi-thread on windows XP.

Eric Ellington
e.ellington at gmail.com
Chicago-talk mailing list
Chicago-talk at pm.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/chicago-talk/attachments/20071213/2bff42c6/attachment.html 

More information about the Chicago-talk mailing list