http://www.perlmonks.org?node_id=165383


in reply to Need Help with Sockets, Please

Well, if you're lucky it may stay connected for a while, but you definitely need to check for $line being undefined, and then re-establish the connection. Otherwise your program will terminate when the socket closes.

You should take a look for POE on CPAN. It's built for exactly this kind of scenario. Bit of a learning curve though.

Also, you need to make sure you do a 'wait' (or define $SIG{SIG_CHLD}) somewhere, otherwhise you'll have problems if the child crashes for some reason!