• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/NetAddr/IP/H08-Jul-2003-12428

t/H08-Jul-2003-2923

ChangesH A D08-Jul-2003321 138

MANIFESTH A D04-Oct-200171 76

Makefile.PLH A D04-Oct-2001304 118

READMEH A D04-Oct-20012 KiB6951

README

1NAME
2    NetAddr::IP::Find - Find IP addresses in plain text
3
4SYNOPSIS
5      use NetAddr::IP::Find;
6      $num_found = find_ipaddrs($text, \&callback);
7
8DESCRIPTION
9    This is a module for finding IP addresses in plain text.
10
11  Functions
12
13    NetAddr::IP::Find exports one function, find_ipaddrs(). It works very
14    similar to URI::Find's find_uris() or Email::Find's find_emails().
15
16      $num_ipaddrs_found = find_ipaddrs($text, \&callback);
17
18    The first argument is a text to search through and manipulate. Second is
19    a callback routine which defines what to do with each IP address as
20    they're found. It returns the total number of IP addresses found.
21
22    The callback is given two arguments. The first is a NetAddr::IP instance
23    representing the IP address found. The second is the actual IP address
24    as found in the text. Whatever the callback returns will replace the
25    original text.
26
27EXAMPLES
28      # For each IP address found, ping its host to see if its alive.
29      use Net::Ping;
30      my $pinger = Net::Ping->new;
31      my %pinged;
32      find_ipaddrs($text, sub {
33                       my($ipaddr, $orig) = @_;
34                       my $host = $ipaddr->to_string;
35                       next if exists $pinged{$host};
36                       $pinged{$host} = $pinger->ping($host);
37                   });
38
39      while (my($host, $up) == each %pinged) {
40          print "$host is " . $up ? 'up' : 'down' . "\n";
41      }
42
43      # Resolve IP address to FQDN
44      find_ipaddrs($text, sub {
45                       my($ipaddr, $orig) = @_;
46                       resolve_ip($ipaddr->to_string);
47                   });
48
49      sub resolve_ip {
50          use Net::DNS;
51          # see perldoc Net::DNS for details
52      }
53
54TODO
55    *   Subnet support.
56
57    *   IPv6 support.
58
59AUTHOR
60    Tatsuhiko Miyagawa <miyagawa@bulknews.net>
61
62    This library is free software; you can redistribute it and/or modify it
63    under the same terms as Perl itself.
64
65SEE ALSO
66    the NetAddr::IP manpage, the URI::Find manpage, the Email::Find manpage,
67    jdresove
68
69