in reply to pause/wait command?
#!/usr/bin/perl use warnings; use strict; use Tk; #read (perldoc -f stat). my $file = shift or die "No file given $!\n"; my $timer; my $lastmtime = (stat $file)[9]; my $mw= tkinit; $mw->withdraw; #make it in background $mw->geometry('+20+20'); #set in upper left corner my $label = $mw->Label( -text => "$file modified at $lastmtime ")->pack(-expand =>1); &startwatchdog($lastmtime); $mw->Button(-text => 'Ok', -command => sub{ $mw->withdraw; $timer->cancel; &startwatchdog( $lastmtime ); })->pack(); MainLoop; sub startwatchdog{ my $mtime = shift; $timer = $mw->repeat(5000, sub { # check every 5 seconds. if ((stat $file)[9] > $lastmtime) { # file was modified. # create your dialog box. $lastmtime = (stat $file)[9]; print "file modified at $lastmtime \n", chr(07); $label->configure(-text =>"$file modified at $lastmtim +e"); $mw->deiconify; $mw->raise; } }); }
|
|---|