#!/usr/bin/perl -w use Tk; use Tk::FileSelect; use strict; my $mw = MainWindow->new; #Solution #1 the next two lines! my $FSref = $mw->FileSelect(-directory=>"C:/"); my $dir = $FSref->Show; #solution #2 up until MainLoop $mw->Label(-text => 'File Name: ')->pack; my $filename = $mw->Entry(-width => 50, -textvariable => "$dir"); $filename->pack; $mw->Button( -text => 'Print', -command => sub{do_print($filename)} )->pack; MainLoop; #used by solution #2, to print the output to the terminal sub do_print { my ($file) = @_; my $file_val = $file->get; print "You selected $file_val\n"; }