<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br>It seems that your $x=<FILE> consumed the whole file.<br>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?<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Eric Ellington <e.ellington@gmail.com><br>To: Chicago.pm chatter <chicago-talk@pm.org><br>Sent: Thursday, December 13, 2007 6:46:26 PM<br>Subject: [Chicago-talk] Why does Perl hate my csv file?<br><br>
Using this script:<br><br>use strict;<br><br>main();<br><br>sub main<br>{<br> open(FILE,"1.csv") || die "COULD NOT OPEN FILE: \n$!\n";<br> #nix header<br> my $x = <FILE>;<br> while (<FILE>)<br> {<br> print $_;<br> }<br>}<br><br>where 1.csv contains:<br>Header<br>RLANE_02,16,0.6,54,58,16,0,0,0,56.3,55.9,11/1/2007,0:00:00,,<br>RLANE_01,8,0.3,56,59,8,0,0,0,112.5,112.2,11/1/2007,0:00:00,,<br>ELANE_02,60,3.9,56,61,32,28,0,0,15,14.4,11/1/2007,0:00:00,,<br>ELANE_01,23,1.3,60,65,13,10,0,0,39.1,38.6,11/1/2007,0:00:00,,<br>WLANE_01,10,0.3,57,58,9,1,0,0,90,89.7,11/1/2007,0:00:00,,<br>WLANE_02,51,3.2,55,60,32,19,0,0,17.6,17.1,11/1/2007,0:00:00,,<br>,,,,,,,,,,,,,,<br><br>I get no output.<br><br>Change the file name to 1.txt and I get output or if I comment out "my<br>$x = <FILE>;" and even then the output
is jacked up. Why is that? Does<br>open do something special when it sees a file that ends in .csv? I<br>found nothing at <a href="http://perldoc.perl.org/functions/open.html" target="_blank">http://perldoc.perl.org/functions/open.html</a> or on<br>ActiveState's website.<br><br>This is perl, v5.8.8 built for MSWin32-x86-multi-thread on windows XP.<br><br>-- <br>Eric Ellington<br><a ymailto="mailto:e.ellington@gmail.com" href="mailto:e.ellington@gmail.com">e.ellington@gmail.com</a><br>_______________________________________________<br>Chicago-talk mailing list<br><a ymailto="mailto:Chicago-talk@pm.org" href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br></div><br></div></div></body></html>