{ my $socket; sub getSocket { unless ($socket && $socket->connected()) { $socket = IO::Socket->new(@_); } $socket; } }