in reply to Perl/Tk threading and/or cron job?

There are a bunch of ways to do this, and using a thread has many ways of returning the data. Here is a way using a reusable thread, returning the data thru shared variables. I've included an Entry widget for you to get terminal input from.
#!/usr/bin/perl use warnings; use strict; use threads; use threads::shared; # uses a reusable thread concept # enter any value in lower entry and the sin() will be # computed in the top entry my $val = 0; # textvariable return variable #create thread before any tk code is called my $data_in:shared = ''; my $data_return:shared = ''; my $go_control:shared = 0; my $die_control:shared = 0; my $thr = threads->new(\&excecute); use Tk; my $mw = MainWindow->new(); # catch window close button to clean up threads $mw->protocol('WM_DELETE_WINDOW' => sub { &clean_exit }); $mw->fontCreate('big', -weight=>'bold', -size=> 14 ); my $label = $mw->Label( -bg=> 'white', -width => 50, -font => 'big', -textvariable => \$val )->pack(); my $txt = $mw->Entry(-bg=>'lemonchiffon', -font => 'big')->pack(qw/-fi +ll x -pady 5/); $mw ->bind('<Any-Enter>' => sub { $txt->Tk::focus }); $txt->bind('<Return>' => \&do_calc ); # initiate a calc whenever a return is hit in the entry widget # you must read the shared var for the txtvar to update # a timer to update label my $timer = $mw->repeat(100,sub{ #every .1 second $val = $data_return; }); # a timer to initiate calculation my $timer1 = $mw->repeat(5000,sub{ #every 5 seconds &do_calc }); MainLoop; sub do_calc{ $data_in = $txt->get() || 0; # set a default value #wake up thread $go_control = 1; } sub clean_exit{ $timer->cancel; $timer1->cancel; my @running_threads = threads->list; if (scalar(@running_threads) < 1){print "\nFinished\n";exit} else{ $die_control = 1; $thr->join; exit; } } sub excecute{ # thread code while(1){ if($die_control){ print "thread finishing\n"; return} #wait for $go_control if($go_control){ if($die_control){ print "thread finishing\n"; return} #do your calculation here $data_return = sin( $data_in) .' '. time ; print "$data_in $data_return\n"; #done calculating, so turn thread back to sleep + $go_control = 0; }else{ select(undef,undef,undef,.25); }# sleep until awakened for next + command } return; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh