#!/usr/bin/perl -w use strict; use Tk; my $FileName; NewWindow( ); MainLoop; sub NewWindow { my $mw = MainWindow->new; $FileName = ""; $mw->Button( -text => "New Window", -width => 16, -command => \&NewWindow )-> grid( -row => 0, -column => 0 ); $mw->Button( -text => "Select File", -width => 16, -command => [ \&ChooseAFile, $mw ] )-> grid( -row => 0, -column => 1 ); $mw->Button( -text => "Exit", -width => 16, -command => sub { $mw->destroy; } )-> grid( -row => 0, -column => 2 ); $mw->Label( -textvariable => \$FileName, -width => 50, -relief => "flat" )-> grid( -row => 1, -column => 0, -columnspan => 3 ); } sub ChooseAFile { my $mw = shift; my @types = ( [ "All files ", '*' ] ); $FileName = $mw->getOpenFile( -filetypes => \@types ); }