in reply to generate range of IP address
*sigh*. Fish.
use constant NUM_TO_MAKE => 2000; my @addrs; my $made = 0; OUTER: for my $i ( 1 .. 254 ) { for my $j ( 1 .. 254 ) { for my $k ( 1 .. 254 ) { for my $l ( 1 .. 254 ) { push @addrs, "$i.$j.$k.$l"; last OUTER if ++$made >= NUM_TO_MAKE; } } } }
And yes, the 254s are intentional. I don't think you want to be generating probable broadcast addresses; if you do, season to taste.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: generate range of IP address
by cjaar (Initiate) on May 21, 2007 at 14:09 UTC | |
by Fletch (Bishop) on May 21, 2007 at 14:43 UTC |