First of all, a little comment on your code: I think there's no need to redefine subroutines inside the for loop all the time. You can move them out of it, unless you have some specific reason not to (on a quick glance, variable scoping ($_) could be an issue).
On your problem: you say you have programmed reboots. If they happen at fixed hours, you could try not to connect to the service at that time. Also, instead of die() you could sleep() for some time, and then try reconnecting again.
in reply to Telnet session disconnect testing