HelloTk.pl

Download hellotk.pl

#!/usr/local/bin/perl -Tw

# Hello World in Perl/Tk
# Written 2004, by Wayne Pollock, Tampa FL USA.

use strict;
use Tk;

my $mw = MainWindow->new;      # Create a new empty window
$mw->title( "Hello World" );   # Set the window title
$mw->geometry( "180x80" );     # Set the width x height [ +X+Y ]

$mw->Label( -text => "Hello, World!", # Add a label
          )->pack( -pady => 10 );

$mw->Button( -text => "Done",  # Add an "exit" button
             -command => sub { exit },
           )->pack( -side => 'bottom' );

MainLoop;                      # Display the window