#!/usr/bin/perl -w use strict; use Tk; my $counter; my $myvar = "Der Zähler steht momentan auf 0."; my $win = MainWindow->new(-background => "#000000"); $win->title("Zählerprogramm"); my $text = $win->Label(-foreground => "white", -background => "#000000", -textvariable => \$myvar); my $button = $win->Button(-text => "+", -foreground => "white", -background => "#000088", -command => sub { handler(1) }); my $button2 = $win->Button(-text => "-", -foreground => "white", -background => "#000088", -command => sub { handler(2) }); $text->pack(); $button->pack(-side => "left"); $button2->pack(-side => "right"); MainLoop; sub handler { my $option = shift; $option == 1 ? ++$counter : --$counter; $myvar = "Der Zähler steht momentan auf $counter."; }