When slightly modifying the examples of reading /etc/passwd
in the POD file, things break in ways I can't explain.
The attached script works fine.
When I initialize csv_tables within the connect statement
(by uncommenting the four commnented lines), it breaks:
execute complains that the file 'dinges' cannot be found.
This happens when I leave the lines that explicitly set csv_tables in,
and also when I remove them.
It even happens when I initialize csv_tables in the connect
statement to {}. Apparently, the initialization keeps the explicit
assignment later from taking effect.
I'm using Cygwin's Perl (see second attachment)
but I've installed and upgraded DBD::CSV with the CPAN shell:
DBI is up to date (1.614).
Text::CSV_XS is up to date (0.73).
SQL::Statement is up to date (1.31).
DBD::File is up to date (0.40).
DBD::CSV is up to date (0.31).
Subject: | csv_tables_bug.pl |
#!/usr/bin/env perl
use warnings;
use strict;
use DBI;
my $dbh = DBI->connect ("dbi:CSV:", undef, undef, {
csv_sep_char => ":",
csv_quote_char => undef,
csv_escape_char => undef,
csv_eol => "\n",
# csv_tables => { dinges => {
# col_names => [qw( login password uid gid realname directory shell )],
# file => '/etc/passwd'
# }}
});
# does *not* work with the csv_tables entry uncommented
$dbh->{csv_tables}{dinges} = {
file => "/etc/passwd",
col_names => [qw( login password uid gid realname directory shell )]
};
# now it *does* work
my $sth = $dbh->prepare ("SELECT * FROM dinges")
or die "prepare failed: ", DBI::errstr, "\n";
$sth->execute
or die "execute failed: ", DBI::errstr, "\n";
while (my $r = $sth->fetchrow_arrayref)
{
print $r->[0], "\n";
}
Subject: | perl-V |
Message body not shown because it is not plain text.