my $but = $mw -> Button(-text=>"Find Directory", -command =>\&get_path) -> pack(); # This is what I used, but it is wrong # my($first) = $but; # &LoadListBox($first); sub get_path { my $filepath = $mw->chooseDirectory() or return(); $ent -> delete(0, 'end'); $ent -> insert(0,"$filepath"); return($filepath); } sub LoadListBox($) { my $test = @_; #$lb->delete('0.1', 'end'); # Just use a plain old grep readdir pipeline to create a list of # filenames for our listbox. opendir (DIR, $test) || die("Cannot open directory"); $lb->insert('end', grep { -f $_ && -r $_ } readdir DIR); close DIR; }