If there is a complete, correct example out there, I'm damned if I can find it.
:-) Yeah, that is why I like using the eventloop method that Glib and Wx use,
where their eventloop can detect conditions like IN , HUP, ERR, etc. I would think if you looked at the c based source code for glib's io::watch method, you will probably find the c code, which allows the eventloop's intelligence to report back IN or HUP, or ERR.
From some discussion I remember from back in my c experiments, there are some sort of error flag set, with values like eagain, einttr, etc. See blocking sockets . That code looks like it could be rewritten in a Perl script, although you may need require 'sys/ioctl.ph';.
P.S. See the low level Perl code, multiplexing server at perl examples