I'm wanting to store the last read position of the LOG into TELLFILE. This
will allow me to return later at the stored location and resume processing.
If the server is restarted, or the process dies, I don't want to process the
same information twice.
The problem, if I don't truncate the file, all positions are stored in the
file when I actually want just the last position. When truncating, the file
grows considerably. What should be only 2-6 bytes ends up being over 200
bytes. Shouldn't truncate(0) clear the file entirely?
I could just write all positions to the file and read the last value in
during startup, but I'm driven to understand why the truncate(0) doesn't
function as expected.
Can anyone tell me why this occurs?
(BTW, I'm doing the flush to make sure that the $curpos is written even if
CTRL+C is used to stop the loop.)
-----------Start code sample---------------
use IO::Handle;
open (TELLFILE, ">tell.tmp") or die "can't open tellfile: $!";
open (LOG, "in001116.log") or die "can't open logfile: $!";
for (;;) {
for ($curpos=tell(LOG);<LOG>;$curpos=tell(LOG)) {
------------>>> TELLFILE->truncate(0);
TELLFILE->print("$curpos");
TELLFILE->flush;
}
sleep 1;
seek(LOG, $curpos, 0);
}
close TELLFILE;
close LOG;
Ken Morehouse II, MCSE
Telergy
IT Operations
Sr NT Administrator
[EMAIL PROTECTED]
(315) 362-2180 (DID)
(315) 362-0203 (FAX)
http://www.telergy.net
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin