in reply to blocking, non-blocking, and semi-blocking
Actually, File::Tail has a select for that very purpose. The way to use it is to pass all the socket filehandles to File::Tail's select exactly the way you'd pass them to the regular select.
Then you take all the File::Tail objects, and you put them behind all the other parameters in the select. Select will return when any of the filehandles are ready for reading, and File::Tail's select will do exactly the same, except it will also return if any of the File::Tail objects have stuff to read.
So, to use File::Tail for this, just replace the undefs in the select call with the appropriate bit vectors for your socket filehandles.foreach (@ARGV) { push(@files,File::Tail->new(name=>"$_",debug=>$debug)); } while (1) { ($nfound,$timeleft,@pending)= File::Tail::select(undef,undef,undef,60,@files); foreach (@pending) { print $_->{"input"}." (".localtime(time).") ".$_->read; } }
|
|---|