in reply to Need a better way to break out a range of addresses...

Since you need to generate valid IP addresses - rejecting nonsense IP's like 192.168.3.256, and following up on grinder's quest, I offer the following code, that uses Net::IP:
use strict; use Net::IP; while (<DATA>){ chomp; generate_range($_); } sub generate_range{ my $range =shift; $range =~s/#.*//; print "\n------ $range -------\n"; my ($lo,$hi); for (split /\./,$range,4){ my ($l,$h) = split /-/; ## print qq[ $_; L=$l H=$h\n] ; $lo .= "$l."; $hi .= ($h || $l ) . "."; } chop for ($lo, $hi); # Drop tralining dots print " $lo - $hi; \n"; my $ip = new Net::IP ("$lo - $hi") || die "No IP$!"; print ( "Number of IPs=" . $ip->size() . "\n"); my $count=0; do { print $ip->ip(), "\t"; } while (++$ip && $count++ <= 20); print "\n"; } __DATA__ 172.17.119.2 # Comments are here... 172.17.119.4-5 # Comments are here... 172.19-21.254.2-3 # Comments are here... 192.168.1.1-3 # Comments are here...
Limiting the output to 20 printed IP's, the output looks like :
------ 172.17.119.2 ------- 172.17.119.2 - 172.17.119.2 ; Number of IPs=1 172.17.119.2 ------ 172.17.119.4-5 ------- 172.17.119.4 - 172.17.119.5 ; Number of IPs=2 172.17.119.4 172.17.119.5 ------ 172.19-21.254.2-3 ------- 172.19.254.2 - 172.21.254.3 ; Number of IPs=131074 172.19.254.2 172.19.254.3 172.19.254.4 172.19.254.5 172.19 +.254.6 172.19.254.7 172. 19.254.8 172.19.254.9 172.19.254.10 172.19.254.11 172.19 +.254.12 172.19.254.13 172. 19.254.14 172.19.254.15 172.19.254.16 172.19.254.17 172.19 +.254.18 172.19.254.19 172. 19.254.20 172.19.254.21 172.19.254.22 172.19.254.23 ------ 192.168.1.1-3 ------- 192.168.1.1 - 192.168.1.3 ; Number of IPs=3 192.168.1.1 192.168.1.2 192.168.1.3
I verified the correct generation of the IP sequence:
172.19.255.0 .. 172.19.255.1

     "Choose a job you like and you will never have to work a day of your life" - Confucius