in reply to Broadcast address: a binary anding question
CPAN is, as ever, your friend. I would use the Net::IPv4Addr module. From the synopsis:
use Net::IPv4Addr qw( :all ); my ($broadcast) = ipv4_broadcast($ip_str, $msk_str);
Where $ip_str and $msk_str in this case (assuming you have (0..255) in your arrays) would be:
$ip_str = join('.', @ip); $msk_str = join('.', @netmask);
If you want to know how your problem is solved in the module, then download it and use the source luke.
|
|---|