{
    "content": [
        {
            "type": "text",
            "text": "# User::pwent (perldoc)\n\n## NAME\n\nUser::pwent - by-name interface to Perl's built-in getpw*() functions\n\n## SYNOPSIS\n\nuse User::pwent;\n$pw = getpwnam('daemon')       || die \"No daemon user\";\nif ( $pw->uid == 1 && $pw->dir =~ m#^/(bin|tmp)?\\z#s ) {\nprint \"gid 1 on root dir\";\n}\n$realshell = $pw->shell || '/bin/sh';\nfor (($fullname, $office, $workphone, $homephone) =\nsplit /\\s*,\\s*/, $pw->gecos)\n{\ns/&/ucfirst(lc($pw->name))/ge;\n}\nuse User::pwent qw(:FIELDS);\ngetpwnam('daemon')             || die \"No daemon user\";\nif ( $pwuid == 1 && $pwdir =~ m#^/(bin|tmp)?\\z#s ) {\nprint \"gid 1 on root dir\";\n}\n$pw = getpw($whoever);\nuse User::pwent qw/:DEFAULT pwhas/;\nif (pwhas(qw[gecos expire quota])) { .... }\nif (pwhas(\"name uid gid passwd\"))  { .... }\nprint \"Your struct pwd has: \", scalar pwhas(), \"\\n\";\n\n## DESCRIPTION\n\nThis module's default exports override the core getpwent(), getpwuid(), and getpwnam()\nfunctions, replacing them with versions that return \"User::pwent\" objects. This object has\nmethods that return the similarly named structure field name from the C's passwd structure from\npwd.h, stripped of their leading \"pw\" parts, namely \"name\", \"passwd\", \"uid\", \"gid\", \"change\",\n\"age\", \"quota\", \"comment\", \"class\", \"gecos\", \"dir\", \"shell\", and \"expire\". The \"passwd\",\n\"gecos\", and \"shell\" fields are tainted when running in taint mode.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (1 subsections)\n- **NOTE**\n- **AUTHOR**\n- **HISTORY**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "User::pwent",
        "section": "",
        "mode": "perldoc",
        "summary": "User::pwent - by-name interface to Perl's built-in getpw*() functions",
        "synopsis": "use User::pwent;\n$pw = getpwnam('daemon')       || die \"No daemon user\";\nif ( $pw->uid == 1 && $pw->dir =~ m#^/(bin|tmp)?\\z#s ) {\nprint \"gid 1 on root dir\";\n}\n$realshell = $pw->shell || '/bin/sh';\nfor (($fullname, $office, $workphone, $homephone) =\nsplit /\\s*,\\s*/, $pw->gecos)\n{\ns/&/ucfirst(lc($pw->name))/ge;\n}\nuse User::pwent qw(:FIELDS);\ngetpwnam('daemon')             || die \"No daemon user\";\nif ( $pwuid == 1 && $pwdir =~ m#^/(bin|tmp)?\\z#s ) {\nprint \"gid 1 on root dir\";\n}\n$pw = getpw($whoever);\nuse User::pwent qw/:DEFAULT pwhas/;\nif (pwhas(qw[gecos expire quota])) { .... }\nif (pwhas(\"name uid gid passwd\"))  { .... }\nprint \"Your struct pwd has: \", scalar pwhas(), \"\\n\";",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 27,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 19,
                "subsections": [
                    {
                        "name": "System Specifics",
                        "lines": 26
                    }
                ]
            },
            {
                "name": "NOTE",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "User::pwent - by-name interface to Perl's built-in getpw*() functions\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use User::pwent;\n$pw = getpwnam('daemon')       || die \"No daemon user\";\nif ( $pw->uid == 1 && $pw->dir =~ m#^/(bin|tmp)?\\z#s ) {\nprint \"gid 1 on root dir\";\n}\n\n$realshell = $pw->shell || '/bin/sh';\n\nfor (($fullname, $office, $workphone, $homephone) =\nsplit /\\s*,\\s*/, $pw->gecos)\n{\ns/&/ucfirst(lc($pw->name))/ge;\n}\n\nuse User::pwent qw(:FIELDS);\ngetpwnam('daemon')             || die \"No daemon user\";\nif ( $pwuid == 1 && $pwdir =~ m#^/(bin|tmp)?\\z#s ) {\nprint \"gid 1 on root dir\";\n}\n\n$pw = getpw($whoever);\n\nuse User::pwent qw/:DEFAULT pwhas/;\nif (pwhas(qw[gecos expire quota])) { .... }\nif (pwhas(\"name uid gid passwd\"))  { .... }\nprint \"Your struct pwd has: \", scalar pwhas(), \"\\n\";\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module's default exports override the core getpwent(), getpwuid(), and getpwnam()\nfunctions, replacing them with versions that return \"User::pwent\" objects. This object has\nmethods that return the similarly named structure field name from the C's passwd structure from\npwd.h, stripped of their leading \"pw\" parts, namely \"name\", \"passwd\", \"uid\", \"gid\", \"change\",\n\"age\", \"quota\", \"comment\", \"class\", \"gecos\", \"dir\", \"shell\", and \"expire\". The \"passwd\",\n\"gecos\", and \"shell\" fields are tainted when running in taint mode.\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 \"pw\" in front their method names. Thus,\n\"$passwdobj->shell\" corresponds to $pwshell if you import the fields.\n\nThe getpw() function is a simple front-end that forwards a numeric argument to getpwuid() and\nthe rest to getpwnam().\n\nTo access this functionality without the core overrides, pass the \"use\" an empty import list,\nand then access function functions with their full qualified names. The built-ins are always\nstill available via the \"CORE::\" pseudo-package.\n",
                "subsections": [
                    {
                        "name": "System Specifics",
                        "content": "Perl believes that no machine ever has more than one of \"change\", \"age\", or \"quota\" implemented,\nnor more than one of either \"comment\" or \"class\". Some machines do not support \"expire\",\n\"gecos\", or allegedly, \"passwd\". You may call these methods no matter what machine you're on,\nbut they return \"undef\" if unimplemented.\n\nYou may ask whether one of these was implemented on the system Perl was built on by asking the\nimportable \"pwhas\" function about them. This function returns true if all parameters are\nsupported fields on the build platform, false if one or more were not, and raises an exception\nif you asked about a field that Perl never knows how to provide. Parameters may be in a\nspace-separated string, or as separate arguments. If you pass no parameters, the function\nreturns the list of \"struct pwd\" fields supported by your build platform's C library, as a list\nin list context, or a space-separated string in scalar context. Note that just because your C\nlibrary had a field doesn't necessarily mean that it's fully implemented on that system.\n\nInterpretation of the \"gecos\" field varies between systems, but traditionally holds 4\ncomma-separated fields containing the user's full name, office location, work phone number, and\nhome phone number. An \"&\" in the gecos field should be replaced by the user's properly\ncapitalized login \"name\". The \"shell\" field, if blank, must be assumed to be /bin/sh. Perl does\nnot do this for you. The \"passwd\" is one-way hashed garble, not clear text, and may not be\nunhashed save by brute-force guessing. Secure systems use more a more secure hashing than DES.\nOn systems supporting shadow password systems, Perl automatically returns the shadow password\nentry when called by a suitably empowered user, even if your underlying vendor-provided C\nlibrary was too short-sighted to realize it should do this.\n\nSee passwd(5) and getpwent(3) for details.\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": []
            },
            "HISTORY": {
                "content": "March 18th, 2000\nReworked internals to support better interface to dodgey fields than normal Perl function\nprovides. Added pwhas() field. Improved documentation.\n",
                "subsections": []
            }
        }
    }
}