#!/usr/bin/perl use strict; use warnings; use diagnostics; use Tk; my $mw = new MainWindow; foreach my $text (qw/eins zwei drei/) { my $b = $mw->Button(-text => "Button Nr. $text") ->pack(-fill => 'x'); $b->bind('' => [ \&printButtonLabel, $text ] ); } MainLoop(); sub printButtonLabel { my $widget = shift; my $text = shift; my $aufschrift = $widget->cget('-text'); print "Button: $text (Aufschrift '$aufschrift') gedrueckt\n"; }