Edit D:\app\Administrator\product\11.2.0\dbhome_1\perl\html\lib\Net\netent.html
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Net::netent - by-name interface to Perl's built-in getnet* functions</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:" /> </head> <body style="background-color: white"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> Net::netent - by-name interface to Perl's built-in getnet* functions</span></strong></big> </td></tr> </table> <!-- INDEX BEGIN --> <div name="index"> <p><a name="__index__"></a></p> <ul> <li><a href="#name">NAME</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> <li><a href="#description">DESCRIPTION</a></li> <li><a href="#examples">EXAMPLES</a></li> <li><a href="#note">NOTE</a></li> <li><a href="#author">AUTHOR</a></li> </ul> <hr name="index" /> </div> <!-- INDEX END --> <p> </p> <h1><a name="name">NAME</a></h1> <p>Net::netent - by-name interface to Perl's built-in getnet*() functions</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> use Net::netent qw(:FIELDS); getnetbyname("loopback") or die "bad net"; printf "%s is %08X\n", $n_name, $n_net;</pre> <pre> use Net::netent;</pre> <pre> $n = getnetbyname("loopback") or die "bad net"; { # there's gotta be a better way, eh? @bytes = unpack("C4", pack("N", $n->net)); shift @bytes while @bytes && $bytes[0] == 0; } printf "%s is %08X [%d.%d.%d.%d]\n", $n->name, $n->net, @bytes;</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p>This module's default exports override the core <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#getnetbyname"><code>getnetbyname()</code></a> and <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#getnetbyaddr"><code>getnetbyaddr()</code></a> functions, replacing them with versions that return "Net::netent" objects. This object has methods that return the similarly named structure field name from the C's netent structure from <em class="file">netdb.h</em>; namely name, aliases, addrtype, and net. The aliases method returns an array reference, the rest scalars.</p> <p>You may also import all the structure fields directly into your namespace as regular variables using the :FIELDS import tag. (Note that this still overrides your core functions.) Access these fields as variables named with a preceding <code>n_</code>. Thus, <code>$net_obj->name()</code> corresponds to $n_name if you import the fields. Array references are available as regular array variables, so for example <code>@{ $net_obj->aliases() }</code> would be simply @n_aliases.</p> <p>The <code>getnet()</code> function is a simple front-end that forwards a numeric argument to <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#getnetbyaddr"><code>getnetbyaddr()</code></a>, and the rest to <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#getnetbyname"><code>getnetbyname()</code></a>.</p> <p>To access this functionality without the core overrides, pass the <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#use"><code>use</code></a> an empty import list, and then access function functions with their full qualified names. On the other hand, the built-ins are still available via the <code>CORE::</code> pseudo-package.</p> <p> </p> <hr /> <h1><a name="examples">EXAMPLES</a></h1> <p>The <code>getnet()</code> functions do this in the Perl core:</p> <pre> sv_setiv(sv, (I32)nent->n_net);</pre> <p>The <code>gethost()</code> functions do this in the Perl core:</p> <pre> sv_setpvn(sv, hent->h_addr, len);</pre> <p>That means that the address comes back in binary for the host functions, and as a regular perl integer for the net ones. This seems a bug, but here's how to deal with it:</p> <pre> use strict; use Socket; use Net::netent;</pre> <pre> @ARGV = ('loopback') unless @ARGV;</pre> <pre> my($n, $net);</pre> <pre> for $net ( @ARGV ) {</pre> <pre> unless ($n = getnetbyname($net)) { warn "$0: no such net: $net\n"; next; }</pre> <pre> printf "\n%s is %s%s\n", $net, lc($n->name) eq lc($net) ? "" : "*really* ", $n->name;</pre> <pre> print "\taliases are ", join(", ", @{$n->aliases}), "\n" if @{$n->aliases};</pre> <pre> # this is stupid; first, why is this not in binary? # second, why am i going through these convolutions # to make it looks right { my @a = unpack("C4", pack("N", $n->net)); shift @a while @a && $a[0] == 0; printf "\taddr is %s [%d.%d.%d.%d]\n", $n->net, @a; }</pre> <pre> if ($n = getnetbyaddr($n->net)) { if (lc($n->name) ne lc($net)) { printf "\tThat addr reverses to net %s!\n", $n->name; $net = $n->name; redo; } } }</pre> <p> </p> <hr /> <h1><a name="note">NOTE</a></h1> <p>While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this.</p> <p> </p> <hr /> <h1><a name="author">AUTHOR</a></h1> <p>Tom Christiansen</p> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> Net::netent - by-name interface to Perl's built-in getnet* functions</span></strong></big> </td></tr> </table> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de