1Net::protoent(3pm)     Perl Programmers Reference Guide     Net::protoent(3pm)
2
3
4

NAME

6       Net::protoent - by-name interface to Perl's built-in getproto*()
7       functions
8

SYNOPSIS

10        use Net::protoent;
11        $p = getprotobyname(shift || 'tcp') || die "no proto";
12        printf "proto for %s is %d, aliases are %s\n",
13           $p->name, $p->proto, "@{$p->aliases}";
14
15        use Net::protoent qw(:FIELDS);
16        getprotobyname(shift || 'tcp') || die "no proto";
17        print "proto for $p_name is $p_proto, aliases are @p_aliases\n";
18

DESCRIPTION

20       This module's default exports override the core getprotoent(),
21       getprotobyname(), and getnetbyport() functions, replacing them with
22       versions that return "Net::protoent" objects.  They take default second
23       arguments of "tcp".  This object has methods that return the similarly
24       named structure field name from the C's protoent structure from
25       netdb.h; namely name, aliases, and proto.  The aliases method returns
26       an array reference, the rest scalars.
27
28       You may also import all the structure fields directly into your
29       namespace as regular variables using the :FIELDS import tag.  (Note
30       that this still overrides your core functions.)  Access these fields as
31       variables named with a preceding "p_".  Thus, "$proto_obj->name()"
32       corresponds to $p_name if you import the fields.  Array references are
33       available as regular array variables, so for example "@{
34       $proto_obj->aliases() }" would be simply @p_aliases.
35
36       The getproto() function is a simple front-end that forwards a numeric
37       argument to getprotobyport(), and the rest to getprotobyname().
38
39       To access this functionality without the core overrides, pass the "use"
40       an empty import list, and then access function functions with their
41       full qualified names.  On the other hand, the built-ins are still
42       available via the "CORE::" pseudo-package.
43

NOTE

45       While this class is currently implemented using the Class::Struct
46       module to build a struct-like class, you shouldn't rely upon this.
47

AUTHOR

49       Tom Christiansen
50
51
52
53perl v5.30.1                      2019-11-29                Net::protoent(3pm)
Impressum