for (0..$#subnets) { # take each subnet and generate the hex out of the subnet divided +by 16 # then the remainder my $pair = hexize((int($subnets[$_]/16)),($subnets[$_]%16)); print $pair; } print "\n";
sprintf makes it easier:
print hexize(@subnets), "\n"; sub hexize { return sprintf("%02x%02x%02x%02x", @_); }
Obviously, Net::IP makes things much easier, as anonymonk pointed out.
In reply to Re: IP to hex translator
by alexm
in thread IP to hex translator
by actualize
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |