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


in reply to Re: Close a file and reopen a new one at midnight
in thread Close a file and reopen a new one at midnight

my $timeout = 24*60*60 - ($hour*3600 + $min*60 + $sec); while(1) { eval { local $SIG{ALRM} = sub { die; }; alarm($timeout); while (my $line = <$sock>) { ................. } alarm(0); }; $timeout = 24*60*60; }