#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new(); my $exit_btn = $mw->Button(-text => "Exit", -command => \&end_program); $exit_btn->pack(); $mw->MainLoop(); sub end_program { # open(my $fh, ">", "logfile"); # print $fh "Application finished.\n"; # close($fh); print "Application finished.\n"; $mw->destroy(); }