Unfortunately my problem still is not fixed (like you suggested)... Here is a new snippit of my code - any other help would be greatly appreciated!
#!/usr/bin/perl use threads; $filename = "/tmp/input.log"; $outputdir = "/var/log/"; $first_event = 1; $position = 0; $time = time(); # Define Timer sub timer { my $counter = 0; while (1) { sleep(1); if ($counter >= 60) { $counter = 0; # #I can't seem to close FILE from the main thre +ad... why? # close (FILE); $outputfile = $outputdir . "log-". time(); open(FILE, "> $outputfile") || die("Can't open + $outputfile to write to"); } $counter++; } } $thr1 = threads->new(\&timer); # Spawn the thread open(TAIL, "tail --follow=name $filename|"); $outputfile = $outputdir . "log-". time(); open(FILE, "> $outputfile") || die("Can't open $outputfile to write to +"); while (<TAIL>) { # do some stuff and print to FILE }
Thanks! Matthew Schnarr
In reply to Re^2: Threading and File Handles
by matt.schnarr
in thread Threading and File Handles
by matt.schnarr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |