Hi All, I was looking for a somewhat standard solution to my need to enhance my hosts list. I would like to support: hosts, ipaddr, ipaddr range, and I think CIDR.
I never knew what the "/xxx" meant when I saw it, still don't know anything about subnets, other than the network folks might want to use then instead of ip address ranges...
I have been looking at NetAddr::IP and I think it will work. I did find that if you specify some IP addresses, the CPU will peg 99% and take 500Megs+ of ram (before ctrl+c) YIKES This might not be safe to use...(my guess is that I specified an invalid range, but since it could happen by accident, I don't want my program to take all the memory, I'd rather it crashed !
What does everyone else use?
Here is the test program I saw...top $hosts line takes TONS of ram and bottom line works
I am open to any suggestions on the format to use
use NetAddr::IP;
#$hosts= '172.21.3.128-172.21.3.140;10.1.1.1;192.168.0.1/8';
#$hosts= '172.21.3.128-172.21.3.140;10.1.1.1;10.0.0.0/30';
push @hosts, split ';', $hosts;
for my $cidr( @hosts ) {
print "$cidr\n";
my $n = NetAddr::IP->new( $cidr );
for my $ip( @{$n->hostenumref} ) {
print "\t", $ip->addr, "\n";
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.