in reply to IP to hex translator

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.