http://www.perlmonks.org?node_id=134734


in reply to Querying a Server Periodically

This code could be adapted to a stateless protocol like HTTP for periodic server queries, I think.
#!/usr/bin/perl -w use strict; use Tk; #set up our window and some interactive feature my $mw = Tk::MainWindow->new(); my $button = $mw->Button( -text => 'Pop', -command => sub {print "pop! +\n";} )->pack(); #set up our periodic task. #this executes faithfully every x milliseconds $mw->repeat(5000, \&waiting ); MainLoop; sub waiting { print "waiting...\n"; }
5000 is the milliseconds amount (so it's a very big number for only 5 seconds, but you can also give number as 5 * 1000 to remind yourself and ease figuring out longer intervals. Give this small script a try, as long as you don't mind locking up the client while the updates are happening you don't have to resort to process forking like the Tk chatterbox does.