in reply to running a loop in background...

You want to fork() that into the background... as such
my $child; unless($child = fork()) { open (FH, "$statusfile") or die "Unable to open file: $!"; my $DELAY = 5; for(;;) { while(<FH>) { print; } sleep $DELAY; seek(FH, 0, 1); } } # continue with main program kill(15, $child); #when you want it to stop
Update wog reminded me kill needed a signal passed!

                - Ant
                - Some of my best work - Fish Dinner

Replies are listed 'Best First'.
Re: Re: running a loop in background...
by Anonymous Monk on Sep 11, 2001 at 00:10 UTC
    This may be a problem that you cannot solve, but after using that code, Dr. Watson strikes. Why am I still using NT? okay that's beside the point. Any ideas on why this would happen?
      From perldoc perlfork:

      On some platforms such as Windows where the fork() system call is not available, Perl can be built to emulate fork() at the interpreter level. While the emulation is designed to be as compatible as possible with the real fork() at the level of the Perl program, there are certain important differences that stem from the fact that all the pseudo child ``processes'' created this way live in the same real process as far as the operating system is concerned.

      In short, YMMV. Make sure you have the latest perl ( >= 5.6.0 ) from ActiveState or whomever built your distribution.

      HTH
      --
      idnopheq
      Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.

      Here is how I sometimes get around this problem.

              - tye (but my friends call me "Tye")
      I have no idea what you can do, except create another script to do this and create a backgrounded win32 process... which I don't know how to do, but can be done... you could also just read a few lines from the log in your idle time...
      for(;;) { do tcl stuff... seek read print }

                      - Ant
                      - Some of my best work - Fish Dinner