Open Source Development Tutorials | Newsletter Signup | About Us
Search  

Go Back   Open Source Tutorials Forum > Programming Languages > Perl Programming
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-21-2007, 07:49 PM
brunogartner brunogartner is offline
Junior Member
 
Join Date: Feb 2007
Posts: 1 brunogartner is on a distinguished road
Default 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 mainen 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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 06:04 PM.


Powered by: vBulletin Version 3.0.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright 2004 - 2006 GrindingGears.com. All Rights Reserved.