【发布时间】:2011-03-12 08:19:45
【问题描述】:
我正在尝试减少此列表中打印的端口数量:
A.B.C.D 80,280,443,515,631,7627,9100,14000
致我最感兴趣的人:
A.B.C.D 80,515,9100
为此,我使用了这段代码:
foreach (@ips_sorted) {
print "$_\t";
my $hostz = $np->get_host($_);
my $port = 0;
my $output = 0;
$port = $hostz->tcp_ports('open');
if ($port == 80 || $port == 445 || $port == 515 || $port == 9100) {
$output = join ',' ,$port;
}
print $output;
print "\n";
}
我可能不需要说它不起作用。我明白了:
A.B.C.D 0
Use of uninitialized value $port in numeric eq (==) at parse-nmap-xml.pl line **(line with if).
【问题讨论】:
-
我们需要更多关于
$hostz->tcp_ports('open')返回的信息。 -
if ($port ~~ (qw(80 445 515 9100)) { ... }怎么样?
标签: perl xml-parsing