my @a=(); @dir=qw(a.txt b.txt c.txt);## LIst of the text files in a directory. my $mw=new MainWindow; for my $i (0..$#dir) { $mw->Checkbutton(-text => $dir[$i], -command=>sub {push @a, $dir[$i]})->pack; } $mw->Button(-text=>"ok",-command=>sub {exit})->pack; MainLoop; print @a;