use warnings; use strict; use Tk; use Date::Calc qw( Today_and_Now Add_Delta_DHMS ); use constant OS_Win => $^O =~ /Win/; my $last_time; my $time_zone = -5; # GMT-5 or, EST. Set TZ appropriately my $mw = MainWindow->new; my $repeat = $mw->repeat( 250, \&update ); MainLoop; sub update{ my ( $year, $month, $day, $hour, $minute, $second ) = Add_Delta_DHMS( Today_and_Now( [localtime] ), 0, $time_zone, 0, 0 ); # Restart the program every day at midnight. Sidestep a bunch of # memory leak problems. if ( ( "$hour$minute$second" eq '000' ) and ( $last_time eq '235959' ) ) { OS_Win ? exec "wperl $0" : exec "perl $0 &"; } $last_time = "$hour$minute$second"; warn "$last_time\n"; # for testing purposes }