2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml">
5 <title>Net::protoent - by-name interface to Perl's built-in getproto* functions
</title>
6 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
7 <link rev=
"made" href=
"mailto:" />
10 <body style=
"background-color: white">
11 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
12 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
13 <big><strong><span class=
"block"> Net::protoent - by-name interface to Perl's built-in getproto* functions
</span></strong></big>
17 <p><a name=
"__index__"></a></p>
22 <li><a href=
"#name">NAME
</a></li>
23 <li><a href=
"#synopsis">SYNOPSIS
</a></li>
24 <li><a href=
"#description">DESCRIPTION
</a></li>
25 <li><a href=
"#note">NOTE
</a></li>
26 <li><a href=
"#author">AUTHOR
</a></li>
33 <h1><a name=
"name">NAME
</a></h1>
34 <p>Net::protoent - by-name interface to Perl's built-in getproto*() functions
</p>
38 <h1><a name=
"synopsis">SYNOPSIS
</a></h1>
41 $p = getprotobyname(shift || 'tcp') || die
"no proto
";
42 printf
"proto for %s is %d, aliases are %s\n
",
43 $p-
>name, $p-
>proto,
"@{$p-
>aliases}
";
</pre>
45 use Net::protoent qw(:FIELDS);
46 getprotobyname(shift || 'tcp') || die
"no proto
";
47 print
"proto for $p_name is $p_proto, aliases are @p_aliases\n
";
</pre>
51 <h1><a name=
"description">DESCRIPTION
</a></h1>
52 <p>This module's default exports override the core getprotoent(),
53 getprotobyname(), and
<code>getnetbyport()
</code> functions, replacing them with
54 versions that return ``Net::protoent'' objects. They take default
55 second arguments of ``tcp''. This object has methods that return the
56 similarly named structure field name from the C's protoent structure
57 from
<em>netdb.h
</em>; namely name, aliases, and proto. The aliases method
58 returns an array reference, the rest scalars.
</p>
59 <p>You may also import all the structure fields directly into your namespace
60 as regular variables using the :FIELDS import tag. (Note that this still
61 overrides your core functions.) Access these fields as variables named
62 with a preceding
<code>p_
</code>. Thus,
<code>$proto_obj-
>name()
</code> corresponds to
63 $p_name if you import the fields. Array references are available as
64 regular array variables, so for example
<code>@{ $proto_obj-
>aliases()
65 }
</code> would be simply @p_aliases.
</p>
66 <p>The
<code>getproto()
</code> function is a simple front-end that forwards a numeric
67 argument to getprotobyport(), and the rest to getprotobyname().
</p>
68 <p>To access this functionality without the core overrides,
69 pass the
<a href=
"file://C|\msysgit\mingw\html/pod/perlfunc.html#item_use"><code>use
</code></a> an empty import list, and then access
70 function functions with their full qualified names.
71 On the other hand, the built-ins are still available
72 via the
<code>CORE::
</code> pseudo-package.
</p>
76 <h1><a name=
"note">NOTE
</a></h1>
77 <p>While this class is currently implemented using the Class::Struct
78 module to build a struct-like class, you shouldn't rely upon this.
</p>
82 <h1><a name=
"author">AUTHOR
</a></h1>
83 <p>Tom Christiansen
</p>
84 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
85 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
86 <big><strong><span class=
"block"> Net::protoent - by-name interface to Perl's built-in getproto* functions
</span></strong></big>