#!/usr/bin/perl # http://perlmonks.org/?node_id=1191710 use strict; use warnings; use Tk; my $count = 0; my $mw = MainWindow -> new; $mw -> Label(-text => 'Counter') ->pack(); $mw -> Label(-textvariable => \$count ) ->pack(); $mw -> Button( -text => 'Count', -command => sub { $count++ } ) ->pack(); MainLoop;