srivasva has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks , I am using Perl/TK for my application. My application needs to be refreshed after certain time interval to gather the data and display. But I am not able to loop perl procedure which gathers data as TK MainLoop takes the control. Below is the sample code :
while(1) { &check_status; ## This method should be called in loop. #sleep($sleeptime); MainLoop; };
Can someone please help me how I can loop my procedure check_status (I am not able to do so since MainLoop takes the control).

Replies are listed 'Best First'.
Re: Perl TK : Looping script to call perl procedure
by zentara (Cardinal) on Jan 21, 2009 at 17:14 UTC
    Never use while(1) loops or sleep in a gui app, unless you really know what you a doing. What you want to do is use a timer
    my $id = $mw->repeat( $sleeptime, \&check_status); # sleeptime is in milliseconds, so 1000 = 1 second # later to cancel it $id->cancel;

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      Awesome... Thanks very much,this is what I was looking for. Thanks for your help.