Perl/Tk Primer

Canonical Tk window A Perl/Tk script consists of three main procedures:
  1. Create a main window
  2. Create and arrange widgets in the window
  3. Wait in a loop for user inputs and actions
The canonical Hello World script contains these three procedures:

#!/usr/bin/perl
use Tk;

# Create a main window
$main = MainWindow->new();

# Create a widget
$label = $main->Label(text  => 'Hello World!');
  
# and arrange it
$label->pack();

# Wait in a loop
MainLoop();