Well, the dotted-decimal IP isn't enough to connect to; it's been a year or two since I did any socket programming with Perl, but I seem to recall you need to use inet_pton() (or is it inet_aton()? Presentation or alpha? I think it's inet_aton() actually), kinda like:
socket(SOCK, AF_INET, getprotobyname('tcp'));
connect(SOCK, sockaddr_in($port, inet_aton($ipOrHostname)));
I may be mixing my C and Perl by this point but I hope that's helpful. If in doubt, perlfunc is always a handy man page. Interestingly, I seem to recall Perl's inet_aton() doesn't mind if you give it a hostname; it'll do the lookup transparently for you.