in reply to Re: Dotless IP address problem
in thread Dotless IP address problem
I guess one could attack the problem using binary shifts (>>) and bitwise and's as well.sub dotless_to_ip { #use integer; my $dotless = shift; my $index = 3; my @ip = (); while ( @ip < 4 ) { my $temp = 256 ** $index--; push @ip, int($dotless / $temp) ; $dotless -= $ip[ -1 ] * $temp; } return join '.', @ip; }
|
|---|