This is working on my pc.
use strict;
use warnings;
my($NEXT_TIME,$FILE_NUMBER,$LOG_FILE);
$NEXT_TIME=time;
$FILE_NUMBER=0;
while(1){
if ( time > $NEXT_TIME )
{
print "Change file next=$NEXT_TIME\n";
thread_log();
}
}
sub thread_log
{
#closing the handler to the current file
if ( -e "log$FILE_NUMBER.log" )
{
close($LOG_FILE);
}
$FILE_NUMBER += 1;
open( $LOG_FILE, '>', "log$FILE_NUMBER.log" )
or die "Unable to open logfile:$!\n";
$NEXT_TIME = $NEXT_TIME + 10;
}
It seems the problem is in other place. How you invoke threads? |