in reply to Re^2: bitwise operators
in thread bitwise operators

And for CIDR notation use this :
use Socket; $net = "192.168.0.0"; $mask = "28"; # /28 is 255.255.255.240 $ip = "192.168.0.5"; print "$ip belongs to $net/$mask\n" if ((net2long($ip) & ~((1 << (32 - + $mask)) - 1 )) == net2long($net)); sub net2long { return unpack("N", inet_aton(shift)); }

2005-01-20 Janitored by Arunbear - added code tags, as per Monastery guidelines