Die 'col_names' scheinen wichtig zu sein. Nochmal komplett:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
# Declare variables
my $db = 'C:/Perlen/csv';
my $prefix = '+49';
# Makes a Datebase Handler
my $dbh = DBI->connect("DBI:CSV:f_dir=$db") or die DBI::errstr;
$dbh->{csv_tables}->{phonebook} =
{
'file' => 'test.csv',
'col_names' => ["ID", "Nummer", "Vorname", "Nachname"],
};
my $sql = qq|
SELECT * FROM phonebook
|;
my $sth = $dbh->prepare( $sql ) or die $dbh->errstr;
$sth->execute() or die $dbh->errstr;
while (my @row = $sth->fetchrow_array()) {
print join "\t", @row;
print "\n";
}
$sth->finish();
$dbh->disconnect();
exit;
\n\n
<!--EDIT|Ronnie|1079890178-->