It's not clear what you really want, but what about this...? sub print_rec() { open (SAVE, ">>c:/save/data.txt"); @key = keys %info; foreach $_ (@key) { print "$_:$info{$_}\n"; print SAVE "$_:$info{$_}\n"; } close SAVE; }
R. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Eric Edwards Sent: 27 May 2004 02:49 To: [EMAIL PROTECTED] Subject: re:Perl Tk Perl Tk Gurus, I am studying Tk using "Mastering Perl TK". I found the below listed code in the book and got it working, Added some stuff to it and it seems to be working OK. I wanted to add "$textundo->Save(?pathname?) so that it saves the contents of the widget to a file. I want this to happen when I click on the "Save" button. I have tried several things but can't get it to work. Any help would be deeply appreciated. The file path is "C:/save". Thanks, Eric #!/usr/bin/perl use Tk; $mw = MainWindow->new; $mw->title("Text: Data Entry"); $f = $mw->Frame->pack(-side => 'bottom'); $f->Button(-text => "Exit", -command => sub {exit;})->pack(-side => 'left'); $f->Button(-text => "Save", -command => sub { &print_rec; })->pack(-side => 'bottom'); $t = $mw->Scrolled("Text", -width => 40, -wrap => 'none')->pack(-expand => 1, -fill => 'both'); foreach (qw/Name Address City State Zip Phone Occupation Company Business_Address Business_Phone/) { $w = $t->Label(-text => "$_:", -relief => 'groove', -width => 20); $t->windowCreate('end', -window => $w); %info; $w = $t->Entry(-width => 20, -textvariable => \$info{$_}); $t->windowCreate('end', -window => $w); $t->insert('end', "\n"); } #$t->configure(-state => 'disabled'); # disallows user typing sub print_rec() { @key = keys %info; foreach $_ (@key) { print "$_:$info{$_}\n"; } } MainLoop; _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs