Thanks Timothy I've added #to remove the trailing end $data2=~s/(^\s+)//g; #pushed it into an array my @records = split(/(\n)/,$data2); and now trying to get Text::CSV_XS to work, which should handle extra commas. Regards Clinton ----- Original Message ----- From: "Timothy Johnson" <[EMAIL PROTECTED]> To: "'Clinton'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, February 26, 2003 6:57 PM Subject: RE: parsing uploaded csv file from HTTP
> > It's late so maybe I'm missing something, but here's one way: > > #throw away the header and keep everything after > "application/octet-stream" > my($junk,$data2) = split(/application\/octet-stream/,$data); > #split the rest up by commas and put it into an array > my @records = split(/,/,$data2); > > Then it's all in a neat little array. This is, of course, assuming that you > don't have any data in your file that has a comma in it... > > -----Original Message----- > From: Clinton [mailto:[EMAIL PROTECTED] > Sent: Tuesday, February 25, 2003 10:34 PM > To: [EMAIL PROTECTED] > Subject: parsing uploaded csv file from HTTP > > > Hi > > I'm trying to parse an uploaded csv file. From the HTTP info I have a string > that looks like this > > Content-Disposition: form-data; name="afile"; > filename="C:\myfolder\mytest.csv" Content-Type: application/octet-stream > 12345678,John Doe 79696676,Superman 215154552,Wilfred DeSilva 216215,Bart > Simpson -----------------------------7d336333d1034e-- > > with some difficulty I've managed to jury-rig a regex > > $data =~ m/(.*[:]\\.*\s.*\s\W+)([\w+\,\w+\s\w+\r\n]+)(-+\w+-{2}\s$)/g; > > which gives me > > 12345678,John Doe 79696676,Superman 215154552,Wilfred DeSilva 216215,Bart > Simpson > > Unfortunately if the CSV file has punctuation (Wilfred De'Silva) everything > falls in a heap. > How can I pull out the data without relying on $2 ([\w+\,\w+\s\w+\r\n]+) > which seems to be the bit that grabs the CSV values > > Running ASP on WinNT box with PerlScript > > Help appreciated > Clinton > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]