En el siguiente ejemplo, se trabaja con Perl, Tk y el modulo DBI para conectarse a una DB de Mysql activa local. Si la conexión es satisfactoria entonces te sale otra ventanita pidiendote que ingreses la consulta SQL a realizar dentro de mysql, luego de obtener los datos estos son imprimidos en una pantalla de la ventana Tk en cuestion.
Para los que tienen dudas de como mezclar Perl/Tk con otros modulos por ejemplo DBI para Mysql.

Código (perl) [Seleccionar]
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use DBI;
my $ventana = MainWindow->new();
$ventana->minsize(qw(400 400));
$ventana->maxsize(qw(400 400));
my $menu = $ventana->Menu(-relief => 'flat');
$ventana->configure( -title => "Proyecto I", -menu => $menu);
my $comando = $menu->Menubutton( -label => "Archivo", -underline => 1);
$comando->command( -label => "Salir", -command => sub { exit(1); } );
my $comando1 = $menu->Menubutton( -label => "Opciones" );
$comando1->command( -label => "Salida", -command => sub { exit(1); } );
my $frama = $ventana->Frame(-borderwidth => 2, -relief => 'groove')->pack();
$frama->Label(-text => "Base de Datos" )->pack();
my $a = $frama->Entry(-width => 20, -background => 'white')->pack(-padx => 10);
$frama->Label(-text => "Usuario" )->pack();
my $b = $frama->Entry(-width => 20, -background => 'white')->pack(-padx => 10);
$frama->Label(-text => "Contrasena" )->pack();
my $c = $frama->Entry(-width => 20, -background => 'white', -show => '*')->pack(-padx => 10, -pady => 10);
my $boton = $ventana->Button(-text => "Conectar", -relief => 'raised', -width => 15, -command => \&conectar )->pack(-pady => 10);
#$ventana->Photo('imagen', -file => 'mysql.gif');
#$ventana->Label(-image => 'imagen', -relief => 'groove')->pack(-pady => 10);
MainLoop();
sub conexión {
my $servidor = $a->get();
my $usuario = $b->get();
my $contrasena = $c->get();
my $conexión = DBI->connect("dbi:mysql:$servidor", $usuario, $contrasena, { PrintError => 0 } );
}
sub conectar {
do conexión;
if ( conexión ) {
my $dialogo = $ventana->messageBox(-message => "Conectado Satisfactoriamente!", -icon => 'warning', -type => 'Ok');
$boton->configure( -state => 'disabled' );
& consulta();
} else {
my $dialogo = $ventana->messageBox(-message => "Error de conexión!!", -icon => 'error', -type => 'Ok');
}
}
sub consulta {
my $ventanita = MainWindow->new();
$ventanita->Label(-text => "Escribe la Consulta")->pack(-padx => 10);
my $consult = $ventanita->Entry(-width => 30, -background => 'white', -foreground => 'red')->pack(-padx => 10);
$ventanita->Button(-text => "Realizar", -width => 20, -relief => 'sunken', -command => sub {
my $consulta1 = $consult->get();
do conexión;
my $peticion = conexión->prepare( qq{$consulta1} ) or my $dialogo = $ventanita->messageBox(-messagebox => "Consulta mal formulada!!", -icon => 'error', -type => 'Ok');
$peticion->execute();
my $texto = $ventanita->Text( -width => 40, -height => 30, -background => 'white' )->pack();
while (my @todo = $peticion->fetchrow_array) {
$texto->insert("end", "@todo ");
$texto->insert("end", "\n");
}
$peticion->finish();
})->pack();
}