http://qs321.pair.com?node_id=1122579

blue_cowdawg has asked for the wisdom of the Perl Monks concerning the following question:

So, in my role as head Puppeteer I don't get to write much Perl like I used to and sure enough I have a need to. I am writing a script that will download from Stop Forum Spam a huge list of toxic CIDR addresses and using that list go generate a Puppet class to put rules into IPTables to drop connections from those CIDR ranges.

I wrote something like this back around 2005 and I remember using a CPAN module that would take a huge list like that, sort the CIDR blocks and merge CIDR blocks as made sense. Worked great. Lasted a long time and as far as I know my client is still using that script.

Problem is as I get older I now realize that memory is the second thing you lose (I forgot what the first was) and I can't remember which CPAN moudle I used to do that. I searched CPAN and I can't find it.

Anyone out there know which module it is?


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; Blog: http://blog.berghold.net Warning: No political correctness allowed.

Replies are listed 'Best First'.
Re: Seeking CPAN module I used once to merge CIDR blocks
by dasgar (Priest) on Apr 06, 2015 at 17:52 UTC

    Doing a quick search, it looks like Net::CIDR::Set provides a merge functionality. Also, it provides a few iterators that returns addresses or CIDR blocks in ascending order. With one of the iterators, I think it's possible to make your own sorting subroutine.

Re: Seeking CPAN module I used once to merge CIDR blocks
by karlgoethebier (Abbot) on Apr 06, 2015 at 17:05 UTC
    ...sort the CIDR blocks and merge CIDR blocks as made sense

    I guess: Net::CIDR::Lite or Net::CIDR?

    Edit: Added link to a node the OP contributed... ;-)

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»