![]() |
|< 1 2 3 4 >| | ![]() |
39 Einträge, 4 Seiten |
print ((-e "c:/pfad/zu/info.csv") ? "existiert" : "existiert nicht");
die $! unless($output);
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
#! /usr/bin/perl
use strict;
use warnings;
use DBI;
use XML::Writer;
use IO::File;
my $output = new IO::File(">output.xml"); die $! unless($output);
my $writer = new XML::Writer(OUTPUT => $output);
my $dbh = DBI->connect("DBI:CSV:f_dir=C:/;csv_sep_char=\\;") or die $DBI::errstr;
$dbh->{'csv_tables'}->{'info'} = { 'file' => 'info2.csv'};
my $sth = $dbh->prepare("SELECT * FROM info");
$sth->execute();
my @names = @{$sth->{NAME}};
while(my @row = $sth->fetchrow_array()){
for(0..$#names){
$writer->startTag($names[$_]);
$writer->characters($row[$_]);
$writer->endTag($names[$_]);
}
}
$sth->finish();
$dbh->disconnect();
$writer->end();
$output->close();
![]() |
|< 1 2 3 4 >| | ![]() |
39 Einträge, 4 Seiten |