{
    "mode": "perldoc",
    "parameter": "Net::protoent",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Net%3A%3Aprotoent/json",
    "generated": "2026-06-12T13:18:51Z",
    "synopsis": "use Net::protoent;\n$p = getprotobyname(shift || 'tcp') || die \"no proto\";\nprintf \"proto for %s is %d, aliases are %s\\n\",\n$p->name, $p->proto, \"@{$p->aliases}\";\nuse Net::protoent qw(:FIELDS);\ngetprotobyname(shift || 'tcp') || die \"no proto\";\nprint \"proto for $pname is $pproto, aliases are @paliases\\n\";",
    "sections": {
        "NAME": {
            "content": "Net::protoent - by-name interface to Perl's built-in getproto*() functions\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Net::protoent;\n$p = getprotobyname(shift || 'tcp') || die \"no proto\";\nprintf \"proto for %s is %d, aliases are %s\\n\",\n$p->name, $p->proto, \"@{$p->aliases}\";\n\nuse Net::protoent qw(:FIELDS);\ngetprotobyname(shift || 'tcp') || die \"no proto\";\nprint \"proto for $pname is $pproto, aliases are @paliases\\n\";\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module's default exports override the core getprotoent(), getprotobyname(), and",
            "subsections": [
                {
                    "name": "getnetbyport",
                    "content": "take default second arguments of \"tcp\". This object has methods that return the similarly named\nstructure field name from the C's protoent structure from netdb.h; namely name, aliases, and\nproto. The aliases method returns an array reference, the rest scalars.\n\nYou may also import all the structure fields directly into your namespace as regular variables\nusing the :FIELDS import tag. (Note that this still overrides your core functions.) Access these\nfields as variables named with a preceding \"p\". Thus, \"$protoobj->name()\" corresponds to\n$pname if you import the fields. Array references are available as regular array variables, so\nfor example \"@{ $protoobj->aliases() }\" would be simply @paliases.\n\nThe getproto() function is a simple front-end that forwards a numeric argument to"
                },
                {
                    "name": "getprotobyport",
                    "content": "To access this functionality without the core overrides, pass the \"use\" an empty import list,\nand then access function functions with their full qualified names. On the other hand, the\nbuilt-ins are still available via the \"CORE::\" pseudo-package.\n"
                }
            ]
        },
        "NOTE": {
            "content": "While this class is currently implemented using the Class::Struct module to build a struct-like\nclass, you shouldn't rely upon this.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Tom Christiansen\n",
            "subsections": []
        }
    },
    "summary": "Net::protoent - by-name interface to Perl's built-in getproto*() functions",
    "flags": [],
    "examples": [],
    "see_also": []
}