use Tk; # The ActiveState compiler does better with "use Tk::Label". use Tk::Label; sub set_time() { ($sec, $min, $hour) = localtime(time); $label->configure(-text => sprintf( "The twenty-four hour time now is $hour:%02d:%02d.", $min, $sec)); } # Create a label as a place to display the time. $label = $MainWindow->new->Label(); # Put the label on-screen. $label->pack; # Every half-second, update the current time in the label. $label->repeat(500, \&set_time); MainLoop;
Example 1: The myclock.pl script.