Created
February 2, 2010 21:05
-
-
Save waffle2k/293029 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Net::CIDR::Lite; | |
use Getopt::Std; | |
my %options=(); | |
my $cidr = Net::CIDR::Lite->new; | |
getopts("n:f:",\%options); | |
if( defined $options{f} ){ | |
open FD, "<$options{f}" or die("Cannot open $options{f}: $!\n" ); | |
while( <FD> ){ | |
chomp; | |
$cidr->add( $_ ); | |
} | |
} else { | |
die("You must specify a cidr address with -n\n" ) unless defined $options{n}; | |
$cidr->add( $options{n} ); | |
} | |
while( <> ){ | |
my $ip = $1 if /\b(\d+\.\d+\.\d+\.\d+)\b/; | |
print if $cidr->find( $ip ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment