In message <[email protected]>, 
Hank Nussbacher <[email protected]> wrote:

>I am looking for a program or website that can take a list of sorted, 
>overlapping prefixes and can reduce it to the most CIDRized format.

I rolled my own some time ago.  It's appended below.

It takes the input cidrs either on the command line or via stdin, one
per line (with no fluff).

It's quite trivial as you can see, but requires the Net::CIDR::Lite
package (which does all of the real work).


========================================================================
#!/usr/bin/perl -w

use strict;
use Net::CIDR::Lite;

my $cidr = Net::CIDR::Lite->new;

sub
process_arg
{
  my ($arg) = @_;

  unless ($cidr->add($arg)) {
    die "Error during add of $arg\n";
  }
}

if (scalar @ARGV) {
  foreach my $arg (@ARGV) {
    process_arg ($arg);
  }
} else {
  while (my $line = <STDIN>) {
    chop $line;
    process_arg ($line);
  }
}

foreach my $c ($cidr->list) {
  print "$c\n";
}

Reply via email to