http://www.perlmonks.org?node_id=118800


in reply to Re: Merge CIDRs
in thread Merge CIDRs

You need to sort by start address. You're lucky that your input data was already sorted by such.

Also, you have to look for $rs <= $ce + 1 rather than $rs == $ce + 1, or you end up not coalescing things like 0-7 (0.0/3), 4-7 (4.0/2), which should just get swallowed.

-- Randal L. Schwartz, Perl hacker