{
    "mode": "perldoc",
    "parameter": "File::stat",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/File%3A%3Astat/json",
    "generated": "2026-06-13T19:43:20Z",
    "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}",
    "sections": {
        "NAME": {
            "content": "File::stat - by-name interface to Perl's built-in stat() functions\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "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}\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",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module's default exports override the core stat() and lstat() functions, replacing them\nwith versions that return \"File::stat\" objects. This object has methods that return the\nsimilarly named structure field name from the stat(2) function; namely, dev, ino, mode, nlink,\nuid, gid, rdev, size, atime, mtime, ctime, blksize, and blocks.\n\nAs of version 1.02 (provided with perl 5.12) the object provides \"-X\" overloading, so you can\ncall filetest operators (\"-f\", \"-x\", and so on) on it. It also provides a \"->cando\" method,\ncalled like\n\n$st->cando( ACCESS, EFFECTIVE )\n\nwhere *ACCESS* is one of \"SIRUSR\", \"SIWUSR\" or \"SIXUSR\" from the Fcntl module, and\n*EFFECTIVE* indicates whether to use effective (true) or real (false) ids. The method interprets\nthe \"mode\", \"uid\" and \"gid\" fields, and returns whether or not the current process would be\nallowed the specified access.\n\nIf you don't want to use the objects, you may import the \"->cando\" method into your namespace as\na regular function called \"statcando\". This takes an arrayref containing the return values of\n\"stat\" or \"lstat\" as its first argument, and interprets it for you.\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 stat() and lstat()\nfunctions.) Access these fields as variables named with a preceding \"st\" in front their method\nnames. Thus, \"$statobj->dev()\" corresponds to $stdev if you import the fields.\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. On the other hand, the\nbuilt-ins are still available via the \"CORE::\" pseudo-package.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "As of Perl 5.8.0 after using this module you cannot use the implicit $ or the special\nfilehandle \"\" with stat() or lstat(), trying to do so leads into strange errors. The workaround\nis for $ to be explicit\n\nmy $statobj = stat $;\n\nand for \"\" to explicitly populate the object using the unexported and undocumented populate()\nfunction with CORE::stat():\n\nmy $statobj = File::stat::populate(CORE::stat());\n",
            "subsections": []
        },
        "ERRORS": {
            "content": "-%s is not implemented on a File::stat object\nThe filetest operators \"-t\", \"-T\" and \"-B\" are not implemented, as they require more\ninformation than just a stat buffer.\n",
            "subsections": []
        },
        "WARNINGS": {
            "content": "These 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 filetest 'access'\" in effect.\n\"File::stat\" will ignore the pragma, and just use the information in the \"mode\" member as\nusual.\n\nFile::stat ignores VMS ACLs\nVMS systems have a permissions structure that cannot be completely represented in a stat\nbuffer, and unlike on other systems the builtin filetest operators respect this. The\n\"File::stat\" overloads, however, do not, since the information required is not available.\n",
            "subsections": []
        },
        "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": "File::stat - by-name interface to Perl's built-in stat() functions",
    "flags": [],
    "examples": [],
    "see_also": []
}