in reply to writing to logfile in a loop
Observe the following code:
use IO::Handle; use strict; $|=1; my $io=new IO::Handle; open LOG,">> mylofile.txt" or die "mylogfile.txt: $!"; $io->fdopen(fileno(LOG),"w+") or die $!; $io->autoflush(1); my $foo=0; while(1){ $foo++; printf "Iteration: %d\n",$foo; $io->printf("Looped in %d\n",$foo); sleep 2; }
I normally don't do Windows, but since I had a VMWare session going I fired up a quick test of your problem. Ran the above code and killed it with the Task Manager and no data was harmed in the making of rhis node. (Everything I expected was in the log file!)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: writing to logfile in a loop
by ikegami (Patriarch) on Nov 21, 2006 at 21:07 UTC | |
by blue_cowdawg (Monsignor) on Nov 21, 2006 at 22:26 UTC | |
by ikegami (Patriarch) on Nov 21, 2006 at 23:28 UTC |