You must be warned of one potential pitfall :
The timeout may seem to
NOT work, if the host you're trying to connect is
unreachable(you may wait long minutes whatever the number of seconds you used in your timeout() function...)
See
this post for more info.
"
Only
Bad
Coders
Badly
Code
In
Perl" (OBC2IP)