Skip to content

Instantly share code, notes, and snippets.

@WanpengQian
Created July 19, 2016 06:54
Show Gist options
  • Save WanpengQian/f34a33b40b97dda1a941dbe6877c2877 to your computer and use it in GitHub Desktop.
Save WanpengQian/f34a33b40b97dda1a941dbe6877c2877 to your computer and use it in GitHub Desktop.
IP range to CIDR format
#!/usr/bin/perl -w
# range2cidr.pl
use Net::CIDR;
use Net::CIDR ':all';
if (@ARGV == 0) {
die "Usage Example: $0 192.168.0.0-192.168.255.255 \n";
}
print join("\n", Net::CIDR::range2cidr("$ARGV[0]")) . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment