{
    "mode": "perldoc",
    "parameter": "FileCache",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/FileCache/json",
    "generated": "2026-06-10T16:03:24Z",
    "synopsis": "no strict 'refs';\nuse FileCache;\n# or\nuse FileCache maxopen => 16;\ncacheout $mode, $path;\n# or\ncacheout $path;\nprint $path @data;\n$fh = cacheout $mode, $path;\n# or\n$fh = cacheout $path;\nprint $fh @data;",
    "sections": {
        "NAME": {
            "content": "FileCache - keep more files open than the system permits\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "no strict 'refs';\n\nuse FileCache;\n# or\nuse FileCache maxopen => 16;\n\ncacheout $mode, $path;\n# or\ncacheout $path;\nprint $path @data;\n\n$fh = cacheout $mode, $path;\n# or\n$fh = cacheout $path;\nprint $fh @data;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The \"cacheout\" function will make sure that there's a filehandle open for reading or writing\navailable as the pathname you give it. It automatically closes and re-opens files if you exceed\nyour system's maximum number of file descriptors, or the suggested maximum *maxopen*.\n\ncacheout EXPR\nThe 1-argument form of cacheout will open a file for writing ('>') on it's first use, and\nappending ('>>') thereafter.\n\nReturns EXPR on success for convenience. You may neglect the return value and manipulate\nEXPR as the filehandle directly if you prefer.\n\ncacheout MODE, EXPR\nThe 2-argument form of cacheout will use the supplied mode for the initial and subsequent\nopenings. Most valid modes for 3-argument \"open\" are supported namely; '>', '+>', '<', '<+',\n'>>', '|-' and '-|'\n\nTo pass supplemental arguments to a program opened with '|-' or '-|' append them to the\ncommand string as you would system EXPR.\n\nReturns EXPR on success for convenience. You may neglect the return value and manipulate\nEXPR as the filehandle directly if you prefer.\n",
            "subsections": []
        },
        "CAVEATS": {
            "content": "While it is permissible to \"close\" a FileCache managed file, do not do so if you are calling\n\"FileCache::cacheout\" from a package other than which it was imported, or with another module\nwhich overrides \"close\". If you must, use \"FileCache::cacheoutclose\".\n\nAlthough FileCache can be used with piped opens ('-|' or '|-') doing so is strongly discouraged.\nIf FileCache finds it necessary to close and then reopen a pipe, the command at the far end of\nthe pipe will be reexecuted - the results of performing IO on FileCache'd pipes is unlikely to\nbe what you expect. The ability to use FileCache on pipes may be removed in a future release.\n\nFileCache does not store the current file offset if it finds it necessary to close a file. When\nthe file is reopened, the offset will be as specified by the original \"open\" file mode. This\ncould be construed to be a bug.\n\nThe module functionality relies on symbolic references, so things will break under 'use strict'\nunless 'no strict \"refs\"' is also specified.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "sys/param.h lies with its \"NOFILE\" define on some systems, so you may have to set *maxopen*\nyourself.\n",
            "subsections": []
        }
    },
    "summary": "FileCache - keep more files open than the system permits",
    "flags": [],
    "examples": [],
    "see_also": []
}