#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = 'Tk::MainWindow'->new(-title => 'File path test'); my $f = $mw->Frame->pack; my $file_w = $f->Entry(-textvariable => \ (my $file = '/')); my $file_b = $f->Button( -text => 'Open File', -command => sub { $file = $mw->getOpenFile }, )->pack; $file_w->pack; my $show_b = $f->Button( -text => 'Show', -command => sub { open my $FH, '<', $file or die $!; print while <$FH>; })->pack; MainLoop();