Compiling Perl/Tk Scripts
by Cameron Laird

Example 1:

use Tk;
sub set_time() {
    ($sec, $min, $hour) = localtime(time);
    $label->configure(-text => sprintf(
         "The twenty-four hour time now is $hour:%02d:%02d.",
         $min, $sec));
        # After another half second, refresh the display again.
    $label->after(500, \&set_time);
}
    # Create a label as a place to display the time.
$label = $MainWindow->new->Label();
    # Put the label on-screen.
$label->pack;
    # Show the current time in the label.
set_time;
MainLoop;



1


