Please use Text::CSV to parse CSV files. It's fast and deals with a ton of subtle issues with these files.
2010/8/10 Levenglick Dov-RM07994 <rm07...@freescale.com> > > Any ideas guys and gals? > > > Best Regards, > Dov Levenglick > SmartDSP OS Development Leader > From: Borowitz Eli-R53547 > Sent: Tuesday, August 10, 2010 15:12 > To: Levenglick Dov-RM07994 > Subject: problem with string length in Perl > > Dov, > > I am trying to read an excel files saved as csv file into perl, > Issue is that some annoying people insist on writing comma’s in the cells > themselves. In that case cell content will be saved > Inside quotes as in “bla,bla,bla”. > So I wrote a routine to clean it up - see below – but if the cell has more > than 256 characters in it will crash. > I know perl string substitution is limited to 256 max length > Any ideas? > > Thanks > > Eli > > # lines are cleared of []{}() before this happens – so match is clean > # get rid of , in fields > while ($line =~ m/\"[^\"]+\"/) > { > $line =~ m/(\"[^\"]+\")/; > $badbit = $1; > $goodbit = $1; > $goodbit =~ s/,/_/g; > $goodbit =~ s/\"//g; > $line =~ s/$badbit/$goodbit/; > print "BB $badbit GB $goodbit \n"; > } > > > > _______________________________________________ > Perl mailing list > Perl@perl.org.il > http://mail.perl.org.il/mailman/listinfo/perl -- Gaal Yahas <g...@forum2.org> http://gaal.livejournal.com/ _______________________________________________ Perl mailing list Perl@perl.org.il http://mail.perl.org.il/mailman/listinfo/perl