P
Prasad Gadgil
Hi,
If I have wrongly posted this here instead of reporting this as a
module bug, pl excuse me.
I am facing an odd bug when using parse() function in Text::CSV module.
This is an absolutely textbook use of the function which fails for some
30 records out of ~ 25000 records.
I have checked, and have found a very strange pattern. In one of the
possible fields which will have embedded commas qualified by double
quotes (like "CN=XX ,OU=XX,OU=XX,DC=XX,DC=XX"), if a pattern line "
,OU" appears, the parse fails... which means if there is a space before
the embedded comma in one of the comma seperated fields, the parse
fails.
This is very puzzling. Can someone help explain.
The code where I exit from the code with parse error is pasted below...
##for each ldap record (every $ads_profile in @ads_datalines),
foreach my $ads_profile (@ads_datalines){
#print STDERR "cycling through ldap records\n";
#@temparray =
(DN,sAMAccountName,givenName,sn,telephoneNumber,department,mail)
my @temparray = ();
my $csv = Text::CSV->new;
if ($csv->parse($ads_profile)) {
@temparray = $csv->fields;
} else {
my $err = $csv->error_input;
print "parse() failed on argument: ", $err, " ", $ads_profile,
"\n";
}
......
If I have wrongly posted this here instead of reporting this as a
module bug, pl excuse me.
I am facing an odd bug when using parse() function in Text::CSV module.
This is an absolutely textbook use of the function which fails for some
30 records out of ~ 25000 records.
I have checked, and have found a very strange pattern. In one of the
possible fields which will have embedded commas qualified by double
quotes (like "CN=XX ,OU=XX,OU=XX,DC=XX,DC=XX"), if a pattern line "
,OU" appears, the parse fails... which means if there is a space before
the embedded comma in one of the comma seperated fields, the parse
fails.
This is very puzzling. Can someone help explain.
The code where I exit from the code with parse error is pasted below...
##for each ldap record (every $ads_profile in @ads_datalines),
foreach my $ads_profile (@ads_datalines){
#print STDERR "cycling through ldap records\n";
#@temparray =
(DN,sAMAccountName,givenName,sn,telephoneNumber,department,mail)
my @temparray = ();
my $csv = Text::CSV->new;
if ($csv->parse($ads_profile)) {
@temparray = $csv->fields;
} else {
my $err = $csv->error_input;
print "parse() failed on argument: ", $err, " ", $ads_profile,
"\n";
}
......