root/NetAddr-IP-Find/trunk/README

Revision 270 (checked in by miyagawa, 19 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 NAME
2     Net::IPAddr::Find - Find IP addresses in plain text
3
4 SYNOPSIS
5       use Net::IPAddr::Find;
6       $num_found = find_ipaddrs($text, \&callback);
7
8 DESCRIPTION
9     This is a module for finding IP addresses in plain text.
10
11   Functions
12
13     Net::IPAddr::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
27 EXAMPLES
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
54 TODO
55     *   Subnet support.
56
57     *   IPv6 support.
58
59 AUTHOR
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
65 SEE ALSO
66     the NetAddr::IP manpage, the URI::Find manpage, the Email::Find manpage,
67     jdresove
68
Note: See TracBrowser for help on using the browser.