Subject: | Net::Gopher sticky errors |
IO::Socket sets $@ to an error string if new() fails to connect, but IO::Socket doesn't reset $@ for each call to new. Net::Gopher request(), rather than checking the return value of IO::Socket::INET->new(), looks at $@ to see if new() failed to connect. This means that if one request() call fails to connect, then all subsequent ones will as well, since $@ will contain the same error string and request() will look to it to determine success or failure.
Net::Gopher request() also doesn't reset _network_error(), so if a request() call fails elsewhere, it will appear to have failed in the exact same way again and again for each subsequent request() call using the same Net::Gopher object.
To fix these problems, Net::Gopher MUST reset $self->_network_error at the beginning of request(), and then must either reset $@ before calling IO::Socket::INET->new or check the return value of the call to new() instead of looking at $@.