Well, of course it will hang, as the telnet session will be dropped immediately after you tell the remote server to reboot. I don't know the best method to solve this, but one alternative would be to setup an alarm.
http://perldoc.perl.org/functions/alarm.html
I would also enclose that particular telnet command in an eval statement to trap the alarm call as well. Then do the appropriate cleanup associated with the fact that the telnet session is defunct. Something like this:
-
eval {
-
alarm 5;
-
$t->cmd("reboot");
-
alarm 0;
-
};
-
# Proceed with cleanup
-