#!/usr/bin/perl use warnings; use strict; use Tk; my $defaultdir = '/home'; #defaults to current dir my $mw = MainWindow->new( -title => "Test DirSelect" ); my $selbut = $mw->Button( -text => 'Select', -command => [ \&dirsel, $defaultdir ] )->pack(); my $quitbut = $mw->Button( -text => 'Exit', -command => sub { exit } )->pack(); MainLoop; ################################################# sub dirsel { my $defaultdir = shift; my $dir = $mw->chooseDirectory( -initialdir => $defaultdir ); print "$dir\n"; } __END__