Glad it seems to be working for you but do take a peek at the source-code of that module's implementation. A Perl program could find itself on an internal network – therefore with a non-public, non-routable IP address – and sometimes that IP does not
a public gateway that it can reach. The internal IP might well not correspond to any external IP address at all. There is no "generalized solution" to this question; sometimes, it cannot be answered.