It's probably a lot easier than this:
Note the use of pack and unpack here.use Socket; + my $ip = '127.0.0.1'; + my $int = ip_to_int($ip); + print $int,"\n"; + print int_to_ip($int); + sub int_to_ip { my ($int) = @_; return inet_ntoa(pack('N', $int)); } + sub ip_to_int { my ($ip) = @_; return unpack('N', inet_aton($ip)); }
/J\
In reply to Re: IP operation trouble
by gellyfish
in thread IP operation trouble
by fauria
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |