Without seeing your code, I highly recommend select, or the IO::Select module. I believe perlipc goes into great detail and provides some good examples of how to use this.
You might also like merlyn's WebTechniques columns, several of which have highly-commented examples.