#!f:/perl/bin/perl use strict; use warnings; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use GD::Graph::pie; use DBI; use FindBin; ### Datenbankverbindung ### my $dbh = DBI->connect("DBI:CSV:f_dir=".$FindBin::Bin.";csv_sep_char=\\;") or die $DBI::errstr; my $stmt = "SELECT * FROM Kunde"; my $sth = $dbh->prepare($stmt) or die $dbh->errstr(); $sth->execute() or die $dbh->errstr(); my @res = ([qw/DHL K_N Hellmann/]); while (my @werte = $sth->fetchrow_array()) { push @res, [@werte]; } $sth->finish(); $dbh->disconnect; ### Grafikeigenschaften festlegen ### my $graph = new GD::Graph::pie(300, 300); $graph->set( title => 'Auswertung', label => 'Category', axislabelclr => 'black', '3d' => 1, start_angle => 90, suppress_angle => 5, ) or die $graph->error; ### Ausgabe ### my $format = $graph->export_format; print header("image/$format"); binmode STDOUT; my $gd = $graph->plot(\@res) or die $graph->error; print $gd->gif();