Yurttas/PL/SL/perl/F/11/00/01/p 01.pl

Revision as of 19:10, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="perl" line start="1" enclose="div">#!/usr/bin/perl use Tk; my $window = MainWindow->new; $window->title("A first Tk Demo"); $window->Label(-text...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 1#!/usr/bin/perl
 2
 3use Tk;
 4
 5my $window = MainWindow->new;
 6$window->title("A first Tk Demo");
 7$window->Label(-text => "This is a chunk of descriptive text")->pack;
 8$window->Button(-text => "Print a value", -command => \&but )->pack;
 9$window->Button(-text => "Double the value", -command => sub {$val*=2} )->pack;
10$window->Button(-text => "This is a quit button ", -command => \&finito )->pack;
11MainLoop;
12
13###############################################
14
15sub but {
16print "value is $val\n";
17}
18
19sub finito{
20print "going away ...\n";
21print "final value is $val\n";
22exit;
23}
24
25sub BEGIN {
26$val = 2;
27}