Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can calculate the broadcast IP from an IP address and netmask in Perl?

Tags:

perl

Does someone have example in Perl of how I can calculate the broadcast IP from an IP address and netmask?

like image 520
shulus Avatar asked Sep 21 '10 19:09

shulus


1 Answers

This can be done with the CPAN modules Net::IP and Net::Netmask:

my $ip = Net::IP->new('192.168.1.1');
my $block = Net::Netmask->new('192.168.1.1');

print "netmask: ", $ip->mask(), "\n";
print "broadcast: ", $block->broadcast(), "\n";
like image 54
Ether Avatar answered Sep 29 '22 20:09

Ether