
02-21-2007, 07:49 PM
|
|
Junior Member
|
|
Join Date: Feb 2007
Posts: 1
|
|
tk buttons
My intentions are to create a program that does just this, has an exit button and a button that creates a random file but i cant seem to figure out how to put the command to make that file into the button action. Can somebody help me out?
It also gives me this error
Illegal declaration of subroutine main  en at tk.pl line 14
Code:
#Tk program that has exit button and open file button that #creates
#text file when pressed.
use Tk;
use IO::File;
my $mw = MainWindow->new;
$mw->title("File Maker");
$mw->Button(-text => "Exit", -command => sub { exit } )->pack;
$mw->Button(-text => "Open File", -command =>
sub open (FILEHANDLE, "<hello.txt") or die ("Cannot do it");
print <FILEHANDLE>;
close (FILEHANDLE);
MainLoop
|