[Israel.pm] FW: problem with string length in Perl
Levenglick Dov-RM07994
RM07994 at freescale.com
Tue Aug 10 10:53:16 PDT 2010
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";
}
More information about the Perl
mailing list