in reply to perl talking to a load balancer

You have other options as well. Use Net::Telnet. Or, even though this is on port 23 I doubt it implements telnet fully.

(beware of buffering problems as well. You might want to try a $foundry->autoflush(1) in there...)

A better solution for these kinds of problems (conversations) is to use the Expect module. It's built for these kinds of things.