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

tiger peng tigerpeng2001 at yahoo.com
Thu Dec 13 20:32:46 PST 2007

it seems that all line end with carriage return character (ascii octal num 15) only. There is no line feed (newline character in Unix)

I made one in Linux and you can see the difference:

gpeng at linbay:/home/gpeng/perl
-> perl  -ne 'print $_' 2.csv
gpeng at linbay:/home/gpeng/perl
-> perl  -ne 'print $_,"\n"' 2.csv

gpeng at linbay:/home/gpeng/perl
-> perl -015  -ne 'print $_,"\n"' 2.csv  # use carriage character as recorder separator

gpeng at linbay:/home/gpeng/perl

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

I am creating everything on a windows system. I checked the line
endings and they look OK to me. Like I said the file works with any
other extension besides csv. Giving it .123 worked.

The output is jacked up in the windows cmd terminal, all of the output
is printed on the same line. I can watch it overwrite it self and then
I just get some data smashed
onto one line.

Cut and Pasted:

This is a scaled down version of something larger. However, I am
having the exact same problem with the code I posted and I am just
testing with a different file which I attached to this email. If there
are any weird characters I am not sure what they are or how they are
messing things up. I see nothing but CR's on every line and one LF on
the final line.

I also turned on use warnings but got no warnings.

On Dec 13, 2007 6:49 PM, Andy Lester <andy at petdance.com> wrote:
> On Dec 13, 2007, at 6:46 PM, Eric Ellington wrote:
> > Change the file name to 1.txt and I get output or if I comment out
> > $x = <FILE>;" and even then the output is jacked up. Why is that?
> > 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.
> No, Perl doesn't care at all.  There's something else going on that
> you're not describing.  Are the line-endings different for your
> machine from the machine that you got the file from?  You're on Unix
> and it came from Windows, or vice versa?
> Also, although "use strict" is a good thing, even more important is
> "use warnings".
> Throw that in and see what else happens.  And what does "the output
> jacked up" mean, anyway?
> xoox,
> Andy
> --
> Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk

Eric Ellington
e.ellington at gmail.com

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

More information about the Chicago-talk mailing list