#!/usr/bin/perl use DBI; use Encode; $| = 1; binmode STDOUT, ":utf8"; main(); sub main { my ($dbh,$select,$body,@row); binmode STDOUT, ":utf8"; $body = "Content-type:text/html; charset=utf-8\r\n\r\n"; $body .= ''; $dbh = DBI->connect('DBI:mysql:database=testdatabase:host=::','root','',{mysql_enable_utf8 => 1}) or die 'Could not connect'; # connect to the database $select = $dbh->prepare('SELECT testvalue FROM utf8test'); $select->execute; while(@row = $select->fetchrow_array) { $body .= "$row[0]
\n"; } $body .= ''; #$body = encode_utf8($body); print $body; return 1; }