#!/usr/bin/perl use strict; use warnings; use threads; use threads::shared; use Tk; my $count:shared=0; my $thread = threads->new( \&launch_thread )->detach; my $mw = MainWindow->new(); $mw->geometry("600x400+100+100"); my $l1 = $mw->Label(-textvariable => \$count)->pack(); MainLoop; sub launch_thread { while (1){ $count++; print "$count\n"; sleep 1; } }