#! /usr/bin/perl use strict; use warnings; use DBI; use XML::Writer; use IO::File; my $output = new IO::File(">output.xml"); my $writer = new XML::Writer(OUTPUT => $output); my $dbh = DBI->connect("DBI:CSV:csv_sep_char=\\;") or die $DBI::errstr; $dbh->{'csv_tables'}->{'info'} = { 'file' => 'info.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();