Turning number ranges into prefixes
`the.lusercop' at lusercop.net
Thu Aug 24 08:23:31 BST 2006
On Wed, Aug 23, 2006 at 07:57:11PM +0100, McGlinchy, Alistair wrote:
> Maybe have a look at Net::Netmask. There's a sub in there called
> irange2cidrlist which finds the smallest number of network blocks to
> cover a given range of IP addresses which is sort of what you want.
> <waves hands madly> I presume the binary manipulation in this module can
> be munged like the above. The code is short on comments though (ie
> none) so may be like turning a sausage back into a pig .
It's fairly easy, in general, to do this for netmasks because of the
binary property - you find the one that covers most - trivial, as pointed
out, and then take stuff that doesn't match away. In the decimal case, I
suspect it's a lot harder.
> Interesting problem though. I may ponder further ...
Similarly - if I had time to do so :-(
Lusercop.net - LARTing Lusers everywhere since 2002
More information about the london.pm