DBD::CSV: Problem with file-name-extensions

Posted by sid_com on Stack Overflow See other posts from Stack Overflow or by sid_com
Published on 2010-05-07T06:52:12Z Indexed on 2010/05/07 6:58 UTC
Read the original article Hit count: 314

Filed under:
|
|
|
|

In this script I have problems with file-name-extensions: if I use /home/mm/test_x it works, with file named /home/mm/test_x.csv it doesn't:

#!/usr/bin/env perl
use warnings; use strict;
use 5.012;
use DBI;

my $table_1 = '/home/mm/test_1.csv';
my $table_2 = '/home/mm/test_2.csv';
#$table_1 = '/home/mm/test_1';
#$table_2 = '/home/mm/test_2';

my $dbh = DBI->connect( "DBI:CSV:" );
$dbh->{RaiseError} = 1;

$table_1 = $dbh->quote_identifier( $table_1 );
$table_2 = $dbh->quote_identifier( $table_2 );

my $sth = $dbh->prepare( "SELECT a.id, a.name, b.city FROM $table_1 AS a NATURAL JOIN $table_2 AS b" );

$sth->execute;
$sth->dump_results;
$dbh->disconnect;

Output with file-name-extention:

DBD::CSV::st execute failed:
Execution ERROR: No such column '"/home/mm/test_1.csv".id' called from /usr/local/lib/perl5/site_perl/5.12.0/x86_64-linux/DBD/File.pm at 570.

Output without file-name-extension:

'1', 'Brown', 'Laramie'
'2', 'Smith', 'Watertown'
2 rows

Is this a bug?

© Stack Overflow or respective owner

Related posts about perl

Related posts about dbi