Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Net IP

by shmem (Canon)
on May 28, 2013 at 16:27 UTC ( #1035642=note: print w/ replies, xml ) Need Help??

in reply to Net IP

I need to write a subnet mask calculator with perl. The extension Net::IP is really powerful.

Well, you could use that module. First thing to do is read its documentation, and off you go. Come back with some code to discuss.

Alternatively I just happen to have a calculator in my toolbox for calculating network, netmask and broadcast out of an IPv4 address in CIDR notation which could be worth being studied by you:

#!/usr/bin/perl # file cidr $m=pack B32,pop=~'/'x$'; printf"$` network %vd broadcast %vd netmask %vd\n",($z=eval$`)&$m,$z|~ +$m,$m; __END__ Example: cidr network broadcast netm +ask
Consult the perl documentation for its various operators, perl special variables and internal functions.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2016-07-01 10:02 GMT
Find Nodes?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...

    Results (409 votes). Check out past polls.