in reply to PIPE problem

Your net.pl missing bracket. It would be difficult for people to understand and help.

By the way, I would suggest you to indent your code ;-)

Update:

A common situation for pipe close to fail is that, IO buffer is not flushed.