Steve Sotis wrote:
> 
> winsock offers an inet_addr function which converts a dotted IP address to
> an unsigned long.
> 
> Is there an equivalent Perl function in any library? A search of
> ActiveState does not seem to turn up one.

I know that this is not immediately apparent in the Perl docs --
especially, if you expect to find this via perldoc -f/-q; but, take
alook at the following:

#! perl.exe -w
use Socket;
use strict;
while (<>) {
        print test_ip($_)
                ? "GOOD: $_\n\n"
                : "BAD: $_\n\n"
}
sub test_ip {
        chomp;
        return $_ eq ( join '.', unpack("C*", inet_aton($_)) ) ? 1 : 0;
}
exit;


If you follow this test for valid ip address, then you can go into
Socket.pm, &c. and learn that much can be done with inet_aton, inet_ntoa
and pack.

Hope this helps . . .

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to