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:
# file cidr
printf"$` network %vd broadcast %vd netmask %vd\n",($z=eval$`)&$m,$z|~
220.127.116.11 network 18.104.22.168 broadcast 22.214.171.124 netm
Consult the perl documentation
for its various operators
, perl special variables
and internal functions