in reply to Daemon problem with sleep()

Or instead of autoflushing, use a \n to force the flush.
## Daemon Loop ## while (1) { print LOG "before sleep...\n"; sleep(1); print LOG "after sleep...\n"; }

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: Daemon problem with sleep()
by almut (Canon) on Dec 17, 2008 at 12:26 UTC

    I think newlines wouldn't help here, as the LOG handle isn't 'interactive' (such as when connected to a tty). Virtually anything else is by default block-buffered (as opposed to line-buffered in the interactive case).

Re^2: Daemon problem with sleep()
by ikegami (Patriarch) on Dec 17, 2008 at 14:13 UTC

    \n only flushes when writing to STDOUT and only when it's connected to a terminal. That's not the case here.

    Autoflushing can be turned on using

    use IO::Handle qw( ); LOG->autoflushing(1);

      Is that the same as $|++;?

      I'm so adjective, I verb nouns!

      chomp; # nom nom nom

        $| affects the currently selected file handle (normally STDOUT).

        $|++;

        is a weird way of saying

        $|=1;

        and it's equivalent to

        select()->autoflush(1);

        But when acting on the same file handle, $|=1; and ->autoflush(1) are equivalent.