http://qs321.pair.com?node_id=304631

smackdab has asked for the wisdom of the Perl Monks concerning the following question:

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"; } }