#!/Perl/bin/perl -w use strict; use Tk; my $filename; my $tk_win = MainWindow->new; my $name_entry = $tk_win->Entry->pack; $tk_win->Button(-text=>'Prepare It!', -command=>\&getFilename)->pack; MainLoop; print "Outside the MainLoop now!\n"; print "filename is $filename\n"; sub getFilename { $filename = $name_entry->get; $tk_win->destroy; }