Blog

Converting IP addresses to decimal and back again

sub ip2dec { return unpack('N', pack('C4', split(/./, $_[0]))); }
sub dec2ip { return join '.' => map { ($_[0] >> 8*(3-$_)) % 256 } 0 .. 3; }

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment replies are not available offline