use strict; use warnings; use Tk; my $top = MainWindow->new; $top->geometry('100x100'); $top->Button( -text => 'Open A File', -command => sub{ my $types = [ ['Text Files', [qw/.txt .text .bat/]], ['All Files', ['*']], ]; my $filename = $top->getOpenFile(-title => 'Open File'); if (defined $filename) { spawn('Notepad.exe', $filename) } } )->pack; MainLoop; sub spawn{ # Routine to spawn another perl process and use it to execute an external program my $args = join ' ', @_; unless (-e 'spawn.pl'){ open my $spawn, '>', 'spawn.pl'; print $spawn 'exec @ARGV;'; } if ($^O =~ /Win/) { $args = '"'.$args.'"'; }else{ $args .= ' &'; } system "perl spawn.pl $args"; }