| 1 | package Nmap::Scanner::HostList; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 6 | 2 | my $class = shift; | |||||||||
| 7 | 2 | my $me = { LISTREF => shift }; | |||||||||
| 8 | |||||||||||
| 9 | 2 | my @keys = sort keys %{$me->{LISTREF}}; | |||||||||
| 10 | 2 | $me->{KEYS} = \@keys; | |||||||||
| 11 | |||||||||||
| 12 | 2 | return bless $me, $class; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 2 | ▶ | sub get_next { | ||||||||
|
Subroutine
get_next: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 16 | 2 | return $_[0]->{LISTREF}->{ shift @{$_[0]->{KEYS}} } | |||||||||
| 17 | 2 | ▶ | if @{$_[0]->{KEYS}}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub as_xml { | ||||||||
|
Subroutine
as_xml: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 21 | |||||||||||
| 22 | 0 | my $self = shift; | |||||||||
| 23 | |||||||||||
| 24 | 0 | my $xml; | |||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | while (my $host = $self->get_next()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | ▶ | last unless defined $host; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | $xml .= $host->as_xml(); | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 0 | return $xml; | |||||||||
| 32 | |||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 3 | 1; | |||||||||
| 36 | |||||||||||
| 37 | =pod | ||||||||||
| 38 | |||||||||||
| 39 | =head2 DESCRIPTION | ||||||||||
| 40 | |||||||||||
| 41 | Holds a list of Nmap::Scanner::Host | ||||||||||
| 42 | objects. get_next() returns a host | ||||||||||
| 43 | reference while there are hosts in | ||||||||||
| 44 | the list and returns undef when | ||||||||||
| 45 | the list is exhausted. Hosts are | ||||||||||
| 46 | indexed and sorted internally by primary | ||||||||||
| 47 | IP address. | ||||||||||
| 48 | |||||||||||
| 49 | =head2 get_next() | ||||||||||
| 50 | |||||||||||
| 51 | Return the next Nmap::Scanner::Host from the list, or | ||||||||||
| 52 | undef if the list is empty. | ||||||||||
| 53 | |||||||||||
| 54 | =head2 as_xml() | ||||||||||
| 55 | |||||||||||
| 56 | Returns an XML string representation of all hosts in the list. | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||