|XP is just a number|
IP list generationby ryan (Pilgrim)
|on Feb 16, 2001 at 22:35 UTC||Need Help??|
ryan has asked for the
wisdom of the Perl Monks concerning the following question:
Hi, I am wishing to create some more efficient code that will generate all IPs between two given ones.
I have done it, but it is a terribly huge conditional looping structure with one or two holes.
ie: 10.0.70.1 -> 10.1.50.20 will produce a list of the 60436 IPs that are in this range (to my calculations). It doesn't need to store it, just dump it to the screen or a file.
It needs to accept ANY IP range (as long as the second one is larger than the first).
Also, I need to know the number of IPs that will be generated through a relatively simple calculation rather than running through the loop slowly implementing a counter. I've got lost in the number of conditions that exist.
Do any such scripts exist to anyone's knowledge, or can someone whip up an efficiently coded version?