Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: IP to hex translator

by alexm (Chaplain)
on Aug 14, 2008 at 11:29 UTC ( [id://704328]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://704328]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2026-01-19 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (122 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.