http://qs321.pair.com?node_id=414675

existem has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone
I have a weird problem... I have a CSV file. I would usually load up the file and parse it line by line, but for some reason all the lines appear to be stuck together, so it is one long string of concatinated rows. I presume this is because there are no line breaks? But when I load the file up in my text editor it shows the file as you would expect, with each row on a new line. So i'm a bit confused.

Here is an example of the code I am using:

open FH, "< $csv_file" or die "$!"; foreach my $offer (<FH>) { print "$offer\n"; my @fields = split(',',$offer); } close(FH) or die "$!";

And here are the first few rows of the CSV file:

producttype,price,imageurl,itemname,description,ctpage,smallimageurl,t +opseller,tagline Lifestyle,19.9899997711,http://images.iwoot.com/medium/globri_med.jpg, +Glow Brick,This light leads an exotic double life. By day it's a quie +t mild-mannered acrylic brick; by night it's a show-stopping illumin +ation that lights up as darkness falls...,http://www.dgm2.com/m/iwant +o/b.asp?a=1081&i=14497&c=http://www.iwantoneofthose.com/GLOBRI.htm,ht +tp://images.iwoot.com/thumbs/globri_thu.jpg,0, Toys & Games,11.9899997711,http://images.iwoot.com/medium/glofri_med.g +if,Glow in the dark frisbee,The 175g Discraft Ultra-Star is the offic +ial disc of the Ultimate Players Association - but who cares it's a +Frisbee that glows in the dark so it's a blast in the park!,http://ww +w.dgm2.com/m/iwanto/b.asp?a=1081&i=14497&c=http://www.iwantoneofthose +.com/GLOFRI.htm,http://images.iwoot.com/thumbs/glofri_thu.gif,0, Toys & Games,24.9899997711,http://images.iwoot.com/medium/glx200_med.g +if,AIR ROCKET - GLX-200,The GL-X200 Rocket Launcher powers rockets up + to 250 feet into the air.,http://www.dgm2.com/m/iwanto/b.asp?a=1081& +i=14497&c=http://www.iwantoneofthose.com/GLX200.htm,http://images.iwo +ot.com/thumbs/glx200_thu.jpg,0, Electronics,54.9900016785,http://images.iwoot.com/medium/surhea_med.jp +g,5.1 Surround Sound Headset,Imagine a five speaker surround-sound sy +stem buried in your head without the medical complications and you' +re getting close to the experience of wearing this awesome set of hea +dphones.,http://www.dgm2.com/m/iwanto/b.asp?a=1081&i=14497&c=http://w +ww.iwantoneofthose.com/HEASET.htm,http://images.iwoot.com/thumbs/surh +ea_thu.jpg,0,

Any ideas how I can parse the file?

Thanks, Tom