Skip to content

Instantly share code, notes, and snippets.

@citrin
Created September 14, 2018 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save citrin/96f7539cd09b8392145441f40106acfb to your computer and use it in GitHub Desktop.
Save citrin/96f7539cd09b8392145441f40106acfb to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Net::CIDR::Lite;
my $cidr = Net::CIDR::Lite->new;
while (<>) {
chomp;
m|([.\d]{7,15}(?:/\d{1,2})?)| and $cidr->add_any($1);
}
my @cidr_list = $cidr->list;
my $string = join "\n",@cidr_list;
print $string,"\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment