in reply to Re^3: IP Iterator
in thread IP Iterator

Nope. All you need is the following:

sub ip_fr_dotted { unpack 'N', pack 'C4', split /\./, $_[0] } sub ip_to_dotted { join '.', unpack 'C4', pack 'N', $_[0] } my $start = ip_fr_dotted('10.0.0.0'); my $end = ip_fr_dotted('10.0.0.255'); for (my $ip=$start; $ip<=$end; $ip++) { print(ip_to_dotted($ip), "\n"); }

I didn't use for my $ip ($start..$end) since it doesn't work for IP addresses ≥ 128.0.0.0 on a 32-bit system.