my %messages = (  1 => 'cannot connect to server',  2 => 'unable to send data',); $socket->connect() or logging($socket,$logger,$messages{1})                    and next; sub logging{    my ($sock,$log,$msg) = @_;    $log->write($msg . $sock->errstr());    $sock->disconnect; }