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::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:" />
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::servent - by-name interface to Perl's built-in getserv* 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=
"#examples">EXAMPLES
</a></li>
26 <li><a href=
"#note">NOTE
</a></li>
27 <li><a href=
"#author">AUTHOR
</a></li>
34 <h1><a name=
"name">NAME
</a></h1>
35 <p>Net::servent - by-name interface to Perl's built-in getserv*() functions
</p>
39 <h1><a name=
"synopsis">SYNOPSIS
</a></h1>
42 $s = getservbyname(shift || 'ftp') || die
"no service
";
43 printf
"port for %s is %s, aliases are %s\n
",
44 $s-
>name, $s-
>port,
"@{$s-
>aliases}
";
</pre>
46 use Net::servent qw(:FIELDS);
47 getservbyname(shift || 'ftp') || die
"no service
";
48 print
"port for $s_name is $s_port, aliases are @s_aliases\n
";
</pre>
52 <h1><a name=
"description">DESCRIPTION
</a></h1>
53 <p>This module's default exports override the core getservent(),
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-
>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-
>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>
77 <h1><a name=
"examples">EXAMPLES
</a></h1>
79 use Net::servent qw(:FIELDS);
</pre>
82 my ($service, $proto) = ((split m!/!, shift), 'tcp');
83 my $valet = getserv($service, $proto);
85 warn
"$
0: No service: $service/$proto\n
"
88 printf
"service $service/$proto is port %d\n
", $valet-
>port;
89 print
"alias are @s_aliases\n
" if @s_aliases;
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>
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"> Net::servent - by-name interface to Perl's built-in getserv* functions
</span></strong></big>