Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: IP addresses

by jwest (Friar)
on May 19, 2005 at 14:32 UTC ( #458629=note: print w/ replies, xml ) Need Help??


in reply to IP addresses

Generally, to determine the list of IP addresses associated with a given network, you should consider using Net::Netmask:

use strict; use warnings; use Net::Netmask; my $spec = ...; my $block = Net::Netmask->new2($spec) or die "bad spec"; my $base = $block->base; my $bcast = $block->broadcast; my @ip = $block->enumerate; for (@ip) { next if @ip > 1 and $_ eq $base; next if @ip > 1 and $_ eq $bcast; ... }
See the perldoc for Net::Netmask to see how the network block may be specified. You'll find that it accepts the most intuitive methods.

--jwest


-><- -><- -><- -><- -><-
All things are Perfect
    To every last Flaw
    And bound in accord
         With Eris's Law
 - HBT; The Book of Advice, 1:7


Comment on Re: IP addresses
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://458629]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-07-30 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls