ok, so I thought up a potentially cool way for someone to explain and demonstrate non blocking I/O to someone like me, who's only seen it used in fairly complex situations and stuff.. I would attempt to do it myself, but being that I'm in the middle of a few things right now, I figured I'd ask if someone could either point to a place, or throw up a quick hack that basically does what the UNIX 'tail -f' does?
what would be even cooler, is if you could pass multiple file names to the script and have it do something like:
FILE1: stuff that was written here
FILE1: they couldn't write just one line baby!
FILE2: now someone wrote to me!
FILE1: NO THEY LOVE ME MORE!
FILE2: more stuff here.. blah blah blah

know what I mean?
thought that might be a really spiffy example!

-brad..

Replies are listed 'Best First'.
RE (tilly) 1: more fun with non-blocking I/O..
by tilly (Archbishop) on Oct 06, 2000 at 03:28 UTC
    Actually a good tail implementation is more complex than it looks, and still does not need unbuffered IO.

    I suggest that you look at IO::Select and see if it does not help you figure out how it works.

    ObRandomNote1: You can ask for unbuffered input, but that only unbuffers it from the time you read it. The process writing it to you may (and probably does) use buffering. For tests use Perl scripts that have $| set to 1.

    ObRandomNote2: Buffered IO is usually more efficient.

A reply falls below the community's threshold of quality. You may see it by logging in.