Skip Menu |

This queue is for tickets about the DBD-CSV CPAN distribution.

Report information
The Basics
Id: 20340
Status: resolved
Priority: 0/
Queue: DBD-CSV

People
Owner: Nobody in particular
Requestors: RENEEB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: csv_eol
We have experienced some problems with one script: [code] #!/usr/bin/perl use strict; use warnings; use DBI; my $file = './test.csv'; my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_sep_char=\\;") or die $DBI::errstr; $dbh->{csv_tables}->{'info'} = {file => $file}; my $sth = $dbh->prepare(q~SELECT * FROM info~); $sth->execute(); while(my @row = $sth->fetchrow_array()){ @row = grep{defined $_ }@row; print join("--",@row),"\n"; } $sth->finish();[/code] It works fine under Windows and breaks under Linux. We found out, that we have to set csv_eol to \n. In the sources there is the following line: $opts{'eol'} = $meta->{'eol'} || $dbh->{'csv_eol'} || "\015\012"; Wouldn't it be better to say $opts{'eol'} = $meta->{'eol'} || $dbh->{'csv_eol'} || $/; to use the operating systems' specific newline?
From: RENEEB [...] cpan.org
Jeff emailed me: Because 1) the module was already several years old and widely used when I inherited it and I didn't want to break backward compatability 2) Because, I think using $/ would be a disaster since you'd never be able to depend on consistency within the program since you wouldn't know where or by what that had been set and 3) if we have to make either people who access *nix files or people who access winodws files do something that takes a tiny bit of smarts (like knowing what the line endings are in a file), better depend on the *nix people to figure it out :-). Now that Ubuntu etc. have opened up the field that's less true than it used to be but eight or ten years ago when I made the decision, it seemed like the right one. I'm afraid I still don't see a reason to change it.