#!/usr/bin/perl -l use strict; use warnings; use Tk; { print "Do you want to press some buttons? (Y/N) [Y]"; chomp(my $in=); $in='y' if $in eq ''; my $cmd={ y => sub {}, n => sub { die "So long then...\n"; } }->{lc $in} || redo; $cmd->(); } my $mw=MainWindow->new; $mw->title('Button 2 STDOUT example'); for my $msg (qw/foo bar baz/) { $mw->Button(-text => "Print '$msg' to STDOUT", -command => sub {print $msg})->pack } $mw->Button(-text => 'Exit GUI', -command => [$mw => 'destroy'])->pack; MainLoop; print "It has been unforgettable!"; __END__