root/Net-IPAddr-Find/trunk/README

Revision 166 (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
2
3
4 Net::IPAddr::FinUds(e3r)Contributed Perl DocumentaNteito:n:IPAddr::Find(3)
5
6
7 NNNNAAAAMMMMEEEE
8        Net::IPAddr::Find - Find IP addresses in plain text
9
10 SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
11          use Net::IPAddr::Find;
12          $num_found = find_ipaddrs($text, \&callback);
13
14
15 DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
16        This is a module for finding IP addresses in plain text.
17
18        FFFFuuuunnnnccccttttiiiioooonnnnssss
19
20        Net::IPAddr::Find exports one function, _f_i_n_d___i_p_a_d_d_r_s_(_). It
21        works very similar to URI::Find's _f_i_n_d___u_r_i_s_(_) or
22        Email::Find's _f_i_n_d___e_m_a_i_l_s_(_).
23
24          $num_ipaddrs_found = find_ipaddrs($text, \&callback);
25
26        The first argument is a text to search through and manipu-
27        late. Second is a callback routine which defines what to
28        do with each IP address as they're found. It returns the
29        total number of IP addresses found.
30
31        The callback is given two arguments. The first is a
32        NetAddr::IP instance representing the IP address found.
33        The second is the actual IP address as found in the text.
34        Whatever the callback returns will replace the original
35        text.
36
37 EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
38          # For each IP address found, ping its host to see if its alive.
39          use Net::Ping;
40          my $pinger = Net::Ping->new;
41          my %pinged;
42          find_ipaddrs($text, sub {
43                           my($ipaddr, $orig) = @_;
44                           my $host = $ipaddr->to_string;
45                           next if exists $pinged{$host};
46                           $pinged{$host} = $pinger->ping($host);
47                       });
48
49          while (my($host, $up) == each %pinged) {
50              print "$host is " . $up ? 'up' : 'down' . "\n";
51          }
52
53          # Resolve IP address to FQDN
54          find_ipaddrs($text, sub {
55                           my($ipaddr, $orig) = @_;
56                           resolve_ip($ipaddr->to_string);
57                       });
58
59
60
61
62
63
64 2001-07-09                 perl v5.5.30                         1
65
66
67
68
69
70 Net::IPAddr::FinUds(e3r)Contributed Perl DocumentaNteito:n:IPAddr::Find(3)
71
72
73          sub resolve_ip {
74              use Net::DNS;
75              # see perldoc Net::DNS for details
76          }
77
78
79 TTTTOOOODDDDOOOO
80        +o   Subnet support.
81
82        +o   IPv6 support.
83
84 AAAAUUUUTTTTHHHHOOOORRRR
85        Tatsuhiko Miyagawa <miyagawa@bulknews.net>
86
87        This library is free software; you can redistribute it
88        and/or modify it under the same terms as Perl itself.
89
90 SSSSEEEEEEEE AAAALLLLSSSSOOOO
91        the NetAddr::IP manpage, the URI::Find manpage, the
92        Email::Find manpage, jdresove
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130 2001-07-09                 perl v5.5.30                         2
131
132
Note: See TracBrowser for help on using the browser.