in reply to Tk and MainLoop

There are a few different problems here...
  1. PodMaster's reply is the answer to your main question: your "ok" button invokes exit; the program exits rather than returning from MainLoop; the final print statement is never reached. By following his advice ("ok" button destroys the window rather than exiting the program), you'll see the print-out. But also...

  2. In a Tk GUI, a Checkbutton can be turned on and off any number of times. The callback sub is called every time the user clicks the button (on or off), so the way your code is written, the user could stack the same file name onto @a multiple times, and if the final click turns the button off, the file name is still in the array.

  3. If the directory has a lot of text files, you'll end up creating a lot of Checkbuttons -- does your window layout support this? (For first-time Tk scripters, the answer is usually "no".)

  4. I assume the print @a at the end is just meant for debugging purposes, but it if there are two or file names in the array, they will be printed with nothing to separate them; try print "@a\n" instead -- placing the array in double quotes will cause the items to be printed with a space between them (space is the default value of "$," (output field separator -- see perldoc perlvar).

It would be better to use a Listbox widget to present file names (or even the ready-made Tk::FileSelect, though I think this sort of method is a pain for users). A simple Listbox scales well from just a few elements to hundreds, and it's easy to make it scrollable:

my $list = $mw->Scrolled('Listbox', ...);
(update: forgot to mention -- Listbox does support multiple selections, of course.)