F
Facco Eloelo
I find NetAddr::IP is good.
But the code below returns me nothing.
can some body help me? thx.
#!/usr/bin/perl
use NetAddr::IP;
my $list_file = 'IPlist.txt';
my $segment_file = 'IPsegment.txt';
my $match_file = 'match.txt';
open my $IPsegment, '<', $segment_file or die "Cannot open $in_file: $!";
open my $IPlist, '<', $list_file or die "Cannot open $in_file: $!";
open my $IPmatch, '>', $match_file or die "Cannot open $out_file: $!";
while ( <$IPsegment> ) {
chomp;
$segment=$_;
my $space = NetAddr::IP->new($segment);
while ( <$IPlist> ) {
chomp ($_);
($domain, $domip) = split(/,/, $_);
for my $ip (map {NetAddr::IP->new($_) } $domip)
{
print my $IPmatch $domain,$ip, "\n"
if $space->contains($ip);
}
}
}
--
But the code below returns me nothing.
can some body help me? thx.
#!/usr/bin/perl
use NetAddr::IP;
my $list_file = 'IPlist.txt';
my $segment_file = 'IPsegment.txt';
my $match_file = 'match.txt';
open my $IPsegment, '<', $segment_file or die "Cannot open $in_file: $!";
open my $IPlist, '<', $list_file or die "Cannot open $in_file: $!";
open my $IPmatch, '>', $match_file or die "Cannot open $out_file: $!";
while ( <$IPsegment> ) {
chomp;
$segment=$_;
my $space = NetAddr::IP->new($segment);
while ( <$IPlist> ) {
chomp ($_);
($domain, $domip) = split(/,/, $_);
for my $ip (map {NetAddr::IP->new($_) } $domip)
{
print my $IPmatch $domain,$ip, "\n"
if $space->contains($ip);
}
}
}
--