Not quite sure I understand your comment regarding the subroutines
in reply to Re^2: Telnet session disconnect testing
in thread Telnet session disconnect testing
Usually, you define your functions once, and rarely put them inside the loops (unless there's some tricky busines going on - like constantly defining new subroutines for some specific tasks). Nevertheless, if it's okay with you, and the program works as expected, then there's no problem. Although it's better for readabilly, maintenance, logic of the program, easier debugging, to do otherwise.