{
    "content": [
        {
            "type": "text",
            "text": "# File::stat (perldoc)\n\n**Summary:** File::stat - by-name interface to Perl's built-in stat() functions\n\n**Synopsis:** use File::stat;\n$st = stat($file) or die \"No $file: $!\";\nif ( ($st->mode & 0111) && $st->nlink > 1) ) {\nprint \"$file is executable with lotsa links\\n\";\n}\nif ( -x $st ) {\nprint \"$file is executable\\n\";\n}\nuse Fcntl \"SIRUSR\";\nif ( $st->cando(SIRUSR, 1) ) {\nprint \"My effective uid can read $file\\n\";\n}\nuse File::stat qw(:FIELDS);\nstat($file) or die \"No $file: $!\";\nif ( ($stmode & 0111) && ($stnlink > 1) ) {\nprint \"$file is executable with lotsa links\\n\";\n}\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (21 lines)\n- **DESCRIPTION** (35 lines)\n- **BUGS** (11 lines)\n- **ERRORS** (4 lines)\n- **WARNINGS** (15 lines)\n- **NOTE** (3 lines)\n- **AUTHOR** (2 lines)\n\n## Full Content\n\n### NAME\n\nFile::stat - by-name interface to Perl's built-in stat() functions\n\n### SYNOPSIS\n\nuse File::stat;\n$st = stat($file) or die \"No $file: $!\";\nif ( ($st->mode & 0111) && $st->nlink > 1) ) {\nprint \"$file is executable with lotsa links\\n\";\n}\n\nif ( -x $st ) {\nprint \"$file is executable\\n\";\n}\n\nuse Fcntl \"SIRUSR\";\nif ( $st->cando(SIRUSR, 1) ) {\nprint \"My effective uid can read $file\\n\";\n}\n\nuse File::stat qw(:FIELDS);\nstat($file) or die \"No $file: $!\";\nif ( ($stmode & 0111) && ($stnlink > 1) ) {\nprint \"$file is executable with lotsa links\\n\";\n}\n\n### DESCRIPTION\n\nThis module's default exports override the core stat() and lstat()\nfunctions, replacing them with versions that return \"File::stat\"\nobjects. This object has methods that return the similarly named\nstructure field name from the stat(2) function; namely, dev, ino, mode,\nnlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, and blocks.\n\nAs of version 1.02 (provided with perl 5.12) the object provides \"-X\"\noverloading, so you can call filetest operators (\"-f\", \"-x\", and so on)\non it. It also provides a \"->cando\" method, called like\n\n$st->cando( ACCESS, EFFECTIVE )\n\nwhere *ACCESS* is one of \"SIRUSR\", \"SIWUSR\" or \"SIXUSR\" from the\nFcntl module, and *EFFECTIVE* indicates whether to use effective (true)\nor real (false) ids. The method interprets the \"mode\", \"uid\" and \"gid\"\nfields, and returns whether or not the current process would be allowed\nthe specified access.\n\nIf you don't want to use the objects, you may import the \"->cando\"\nmethod into your namespace as a regular function called \"statcando\".\nThis takes an arrayref containing the return values of \"stat\" or \"lstat\"\nas its first argument, and interprets it for you.\n\nYou may also import all the structure fields directly into your\nnamespace as regular variables using the :FIELDS import tag. (Note that\nthis still overrides your stat() and lstat() functions.) Access these\nfields as variables named with a preceding \"st\" in front their method\nnames. Thus, \"$statobj->dev()\" corresponds to $stdev if you import the\nfields.\n\nTo access this functionality without the core overrides, pass the \"use\"\nan empty import list, and then access function functions with their full\nqualified names. On the other hand, the built-ins are still available\nvia the \"CORE::\" pseudo-package.\n\n### BUGS\n\nAs of Perl 5.8.0 after using this module you cannot use the implicit $\nor the special filehandle \"\" with stat() or lstat(), trying to do so\nleads into strange errors. The workaround is for $ to be explicit\n\nmy $statobj = stat $;\n\nand for \"\" to explicitly populate the object using the unexported and\nundocumented populate() function with CORE::stat():\n\nmy $statobj = File::stat::populate(CORE::stat());\n\n### ERRORS\n\n-%s is not implemented on a File::stat object\nThe filetest operators \"-t\", \"-T\" and \"-B\" are not implemented, as\nthey require more information than just a stat buffer.\n\n### WARNINGS\n\nThese can all be disabled with\n\nno warnings \"File::stat\";\n\nFile::stat ignores use filetest 'access'\nYou have tried to use one of the \"-rwxRWX\" filetests with \"use\nfiletest 'access'\" in effect. \"File::stat\" will ignore the pragma,\nand just use the information in the \"mode\" member as usual.\n\nFile::stat ignores VMS ACLs\nVMS systems have a permissions structure that cannot be completely\nrepresented in a stat buffer, and unlike on other systems the\nbuiltin filetest operators respect this. The \"File::stat\" overloads,\nhowever, do not, since the information required is not available.\n\n### NOTE\n\nWhile this class is currently implemented using the Class::Struct module\nto build a struct-like class, you shouldn't rely upon this.\n\n### AUTHOR\n\nTom Christiansen\n\n"
        }
    ],
    "structuredContent": {
        "command": "File::stat",
        "section": "",
        "mode": "perldoc",
        "summary": "File::stat - by-name interface to Perl's built-in stat() functions",
        "synopsis": "use File::stat;\n$st = stat($file) or die \"No $file: $!\";\nif ( ($st->mode & 0111) && $st->nlink > 1) ) {\nprint \"$file is executable with lotsa links\\n\";\n}\nif ( -x $st ) {\nprint \"$file is executable\\n\";\n}\nuse Fcntl \"SIRUSR\";\nif ( $st->cando(SIRUSR, 1) ) {\nprint \"My effective uid can read $file\\n\";\n}\nuse File::stat qw(:FIELDS);\nstat($file) or die \"No $file: $!\";\nif ( ($stmode & 0111) && ($stnlink > 1) ) {\nprint \"$file is executable with lotsa links\\n\";\n}",
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 35,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "ERRORS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "WARNINGS",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "NOTE",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            }
        ]
    }
}