Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / Net / servent.html
blob05f79cc4b52e534f3328a371d55197e04825bedb
1 <?xml version="1.0" ?>
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">
4 <head>
5 <title>Net::servent - by-name interface to Perl's built-in getserv* functions</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
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">&nbsp;Net::servent - by-name interface to Perl's built-in getserv* functions</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
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="#examples">EXAMPLES</a></li>
26 <li><a href="#note">NOTE</a></li>
27 <li><a href="#author">AUTHOR</a></li>
28 </ul>
29 <!-- INDEX END -->
31 <hr />
32 <p>
33 </p>
34 <h1><a name="name">NAME</a></h1>
35 <p>Net::servent - by-name interface to Perl's built-in getserv*() functions</p>
36 <p>
37 </p>
38 <hr />
39 <h1><a name="synopsis">SYNOPSIS</a></h1>
40 <pre>
41 use Net::servent;
42 $s = getservbyname(shift || 'ftp') || die &quot;no service&quot;;
43 printf &quot;port for %s is %s, aliases are %s\n&quot;,
44 $s-&gt;name, $s-&gt;port, &quot;@{$s-&gt;aliases}&quot;;</pre>
45 <pre>
46 use Net::servent qw(:FIELDS);
47 getservbyname(shift || 'ftp') || die &quot;no service&quot;;
48 print &quot;port for $s_name is $s_port, aliases are @s_aliases\n&quot;;</pre>
49 <p>
50 </p>
51 <hr />
52 <h1><a name="description">DESCRIPTION</a></h1>
53 <p>This module's default exports override the core getservent(),
54 getservbyname(), and
55 <code>getnetbyport()</code> functions, replacing them with versions that return
56 ``Net::servent'' objects. They take default second arguments of ``tcp''. This object has methods that return the similarly
57 named structure field name from the C's servent structure from <em>netdb.h</em>;
58 namely name, aliases, port, and proto. The aliases
59 method returns an array reference, the rest scalars.</p>
60 <p>You may also import all the structure fields directly into your namespace
61 as regular variables using the :FIELDS import tag. (Note that this still
62 overrides your core functions.) Access these fields as variables named
63 with a preceding <code>s_</code>. Thus, <code>$serv_obj-&gt;name()</code> corresponds to
64 $s_name if you import the fields. Array references are available as
65 regular array variables, so for example <code>@{ $serv_obj-&gt;aliases()}</code>
66 would be simply @s_aliases.</p>
67 <p>The <code>getserv()</code> function is a simple front-end that forwards a numeric
68 argument to getservbyport(), and the rest to getservbyname().</p>
69 <p>To access this functionality without the core overrides,
70 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
71 function functions with their full qualified names.
72 On the other hand, the built-ins are still available
73 via the <code>CORE::</code> pseudo-package.</p>
74 <p>
75 </p>
76 <hr />
77 <h1><a name="examples">EXAMPLES</a></h1>
78 <pre>
79 use Net::servent qw(:FIELDS);</pre>
80 <pre>
81 while (@ARGV) {
82 my ($service, $proto) = ((split m!/!, shift), 'tcp');
83 my $valet = getserv($service, $proto);
84 unless ($valet) {
85 warn &quot;$0: No service: $service/$proto\n&quot;
86 next;
88 printf &quot;service $service/$proto is port %d\n&quot;, $valet-&gt;port;
89 print &quot;alias are @s_aliases\n&quot; if @s_aliases;
90 }</pre>
91 <p>
92 </p>
93 <hr />
94 <h1><a name="note">NOTE</a></h1>
95 <p>While this class is currently implemented using the Class::Struct
96 module to build a struct-like class, you shouldn't rely upon this.</p>
97 <p>
98 </p>
99 <hr />
100 <h1><a name="author">AUTHOR</a></h1>
101 <p>Tom Christiansen</p>
102 <table border="0" width="100%" cellspacing="0" cellpadding="3">
103 <tr><td class="block" style="background-color: #cccccc" valign="middle">
104 <big><strong><span class="block">&nbsp;Net::servent - by-name interface to Perl's built-in getserv* functions</span></strong></big>
105 </td></tr>
106 </table>
108 </body>
110 </html>