use Socket; $net = "192.168.0.0"; $mask = "255.255.255.240"; $ip = "192.168.0.5"; print "$ip belongs to $net/$mask\n" if ((net2long($ip) & net2long($mas +k)) == net2long($net)); sub net2long { return unpack("N", inet_aton(shift)); }
2005-01-20 Janitored by Arunbear - added code tags, as per Monastery guidelines
In reply to Re^2: bitwise operators
by Anonymous Monk
in thread bitwise operators
by gtdunlap
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |