Hello Deepika1312 and welcome to the manastery and to the wonderful world of Perl!
from the little I know about networking what you want is not possible: given the lonely IP address you cannot desume what the netmask value is. Infact the net can be subnetted at will resulting in a serie of a little subnets.
If you are looking to the local IP configured in some host you can retrieve how the network card is configured but it can be also misconfigured: so you cannot be sure if the mask is the rigth one.
By other hand if you know the net (not just an IP) you can retrieve useful informations using NetAddr::IP for example (warning windows double quotes!):
perl -MNetAddr::IP -e "$ip=new NetAddr::IP '189.10.136.129/27'; print
+'net ',$ip,' mask ',$ip->mask,' first ',$ip->first,' last ',$ip->last
+"
net 189.10.136.129/27 mask 255.255.255.224 first 189.10.136.129/27 las
+t 189.10.136.158/27
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
|