{
    "mode": "perldoc",
    "parameter": "File::Glob",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/File%3A%3AGlob/json",
    "generated": "2026-06-13T21:26:46Z",
    "synopsis": "use File::Glob ':bsdglob';\n@list = bsdglob('*.[ch]');\n$homedir = bsdglob('~gnat', GLOBTILDE | GLOBERR);\nif (GLOBERROR) {\n# an error occurred reading $homedir\n}\n## override the core glob (CORE::glob() does this automatically\n## by default anyway, since v5.6.0)\nuse File::Glob ':globally';\nmy @sources = <*.{c,h,y}>;\n## override the core glob, forcing case sensitivity\nuse File::Glob qw(:globally :case);\nmy @sources = <*.{c,h,y}>;\n## override the core glob forcing case insensitivity\nuse File::Glob qw(:globally :nocase);\nmy @sources = <*.{c,h,y}>;\n## glob on all files in home directory\nuse File::Glob ':globally';\nmy @sources = <~gnat/*>;",
    "sections": {
        "NAME": {
            "content": "File::Glob - Perl extension for BSD glob routine\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use File::Glob ':bsdglob';\n\n@list = bsdglob('*.[ch]');\n$homedir = bsdglob('~gnat', GLOBTILDE | GLOBERR);\n\nif (GLOBERROR) {\n# an error occurred reading $homedir\n}\n\n## override the core glob (CORE::glob() does this automatically\n## by default anyway, since v5.6.0)\nuse File::Glob ':globally';\nmy @sources = <*.{c,h,y}>;\n\n## override the core glob, forcing case sensitivity\nuse File::Glob qw(:globally :case);\nmy @sources = <*.{c,h,y}>;\n\n## override the core glob forcing case insensitivity\nuse File::Glob qw(:globally :nocase);\nmy @sources = <*.{c,h,y}>;\n\n## glob on all files in home directory\nuse File::Glob ':globally';\nmy @sources = <~gnat/*>;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The glob angle-bracket operator \"<>\" is a pathname generator that implements the rules for file\nname pattern matching used by Unix-like shells such as the Bourne shell or C shell.\n\nFile::Glob::bsdglob() implements the FreeBSD glob(3) routine, which is a superset of the POSIX",
            "subsections": [
                {
                    "name": "glob",
                    "content": "argument, and an optional \"flags\" argument, and returns a list of filenames matching the\npattern, with interpretation of the pattern modified by the \"flags\" variable.\n\nSince v5.6.0, Perl's CORE::glob() is implemented in terms of bsdglob(). Note that they don't\nshare the same prototype--CORE::glob() only accepts a single argument. Due to historical\nreasons, CORE::glob() will also split its argument on whitespace, treating it as multiple\npatterns, whereas bsdglob() considers them as one pattern. But see \":bsdglob\" under \"EXPORTS\",\nbelow.\n\nMETA CHARACTERS\n\\       Quote the next metacharacter\n[]      Character class\n{}      Multiple pattern\n*       Match any string of characters\n?       Match any single character\n~       User name home directory\n\nThe metanotation \"a{b,c,d}e\" is a shorthand for \"abe ace ade\". Left to right order is preserved,\nwith results of matches being sorted separately at a low level to preserve this order. As a\nspecial case \"{\", \"}\", and \"{}\" are passed undisturbed.\n\nEXPORTS\nSee also the \"POSIX FLAGS\" below, which can be exported individually.\n\n\":bsdglob\"\nThe \":bsdglob\" export tag exports bsdglob() and the constants listed below. It also overrides"
                },
                {
                    "name": "glob",
                    "content": "space is treated as part of a file name), but supports iteration in scalar context; i.e., it\npreserves the core function's feature of returning the next item each time it is called.\n\n\":glob\"\nThe \":glob\" tag, now discouraged, is the old version of \":bsdglob\". It exports the same\nconstants and functions, but its glob() override does not support iteration; it returns the last\nfile name in scalar context. That means this will loop forever:\n\nuse File::Glob ':glob';\nwhile (my $file = <* copy.txt>) {\n...\n}\n\n\"bsdglob\"\nThis function, which is included in the two export tags listed above, takes one or two\narguments. The first is the glob pattern. The second, if given, is a set of flags ORed together.\nThe available flags and the default set of flags are listed below under \"POSIX FLAGS\".\n\nRemember that to use the named constants for flags you must import them, for example with\n\":bsdglob\" described above. If not imported, and \"use strict\" is not in effect, then the\nconstants will be treated as bareword strings, which won't do what you what.\n\n\":nocase\" and \":case\"\nThese two export tags globally modify the default flags that bsdglob() and, except on VMS,\nPerl's built-in \"glob\" operator use. \"GLOBNOCASE\" is turned on or off, respectively.\n\n\"cshglob\"\nThe cshglob() function can also be exported, but you should not use it directly unless you\nreally know what you are doing. It splits the pattern into words and feeds each one to"
                },
                {
                    "name": "bsd_glob",
                    "content": "POSIX FLAGS\nIf no flags argument is give then \"GLOBCSH\" is set, and on VMS and Windows systems,\n\"GLOBNOCASE\" too. Otherwise the flags to use are determined solely by the flags argument. The\nPOSIX defined flags are:\n\n\"GLOBERR\"\nForce bsdglob() to return an error when it encounters a directory it cannot open or read.\nOrdinarily bsdglob() continues to find matches.\n\n\"GLOBLIMIT\"\nMake bsdglob() return an error (GLOBNOSPACE) when the pattern expands to a size bigger\nthan the system constant \"ARGMAX\" (usually found in limits.h). If your system does not\ndefine this constant, bsdglob() uses \"sysconf(SCARGMAX)\" or \"POSIXARGMAX\" where\navailable (in that order). You can inspect these values using the standard \"POSIX\"\nextension.\n\n\"GLOBMARK\"\nEach pathname that is a directory that matches the pattern has a slash appended.\n\n\"GLOBNOCASE\"\nBy default, file names are assumed to be case sensitive; this flag makes bsdglob() treat\ncase differences as not significant.\n\n\"GLOBNOCHECK\"\nIf the pattern does not match any pathname, then bsdglob() returns a list consisting of\nonly the pattern. If \"GLOBQUOTE\" is set, its effect is present in the pattern returned.\n\n\"GLOBNOSORT\"\nBy default, the pathnames are sorted in ascending ASCII order; this flag prevents that\nsorting (speeding up bsdglob()).\n\nThe FreeBSD extensions to the POSIX standard are the following flags:\n\n\"GLOBBRACE\"\nPre-process the string to expand \"{pat,pat,...}\" strings like csh(1). The pattern '{}' is\nleft unexpanded for historical reasons (and csh(1) does the same thing to ease typing of\nfind(1) patterns).\n\n\"GLOBNOMAGIC\"\nSame as \"GLOBNOCHECK\" but it only returns the pattern if it does not contain any of the\nspecial characters \"*\", \"?\" or \"[\". \"NOMAGIC\" is provided to simplify implementing the\nhistoric csh(1) globbing behaviour and should probably not be used anywhere else.\n\n\"GLOBQUOTE\"\nUse the backslash ('\\') character for quoting: every occurrence of a backslash followed by a\ncharacter in the pattern is replaced by that character, avoiding any special interpretation\nof the character. (But see below for exceptions on DOSISH systems).\n\n\"GLOBTILDE\"\nExpand patterns that start with '~' to user name home directories.\n\n\"GLOBCSH\"\nFor convenience, \"GLOBCSH\" is a synonym for \"GLOBBRACE | GLOBNOMAGIC | GLOBQUOTE |\nGLOBTILDE | GLOBALPHASORT\".\n\nThe POSIX provided \"GLOBAPPEND\", \"GLOBDOOFFS\", and the FreeBSD extensions \"GLOBALTDIRFUNC\",\nand \"GLOBMAGCHAR\" flags have not been implemented in the Perl version because they involve more\ncomplex interaction with the underlying C structures.\n\nThe following flag has been added in the Perl implementation for csh compatibility:\n\n\"GLOBALPHASORT\"\nIf \"GLOBNOSORT\" is not in effect, sort filenames is alphabetical order (case does not\nmatter) rather than in ASCII order.\n"
                }
            ]
        },
        "DIAGNOSTICS": {
            "content": "",
            "subsections": [
                {
                    "name": "bsd_glob",
                    "content": "&File::Glob::GLOBERROR will be non-zero and $! will be set. &File::Glob::GLOBERROR is\nguaranteed to be zero if no error occurred, or one of the following values otherwise:\n\n\"GLOBNOSPACE\"\nAn attempt to allocate memory failed.\n\n\"GLOBABEND\"\nThe glob was stopped because an error was encountered.\n\nIn the case where bsdglob() has found some matching paths, but is interrupted by an error, it\nwill return a list of filenames and set &File::Glob::ERROR.\n\nNote that bsdglob() deviates from POSIX and FreeBSD glob(3) behaviour by not considering\n\"ENOENT\" and \"ENOTDIR\" as errors - bsdglob() will continue processing despite those errors,\nunless the \"GLOBERR\" flag is set.\n\nBe aware that all filenames returned from File::Glob are tainted.\n"
                }
            ]
        },
        "NOTES": {
            "content": "*   If you want to use multiple patterns, e.g. \"bsdglob(\"a* b*\")\", you should probably throw\nthem in a set as in \"bsdglob(\"{a*,b*}\")\". This is because the argument to bsdglob() isn't\nsubjected to parsing by the C shell. Remember that you can use a backslash to escape things.\n\n*   On DOSISH systems, backslash is a valid directory separator character. In this case, use of\nbackslash as a quoting character (via GLOBQUOTE) interferes with the use of backslash as a\ndirectory separator. The best (simplest, most portable) solution is to use forward slashes\nfor directory separators, and backslashes for quoting. However, this does not match \"normal\npractice\" on these systems. As a concession to user expectation, therefore, backslashes\n(under GLOBQUOTE) only quote the glob metacharacters '[', ']', '{', '}', '-', '~', and\nbackslash itself. All other backslashes are passed through unchanged.\n\n*   Win32 users should use the real slash. If you really want to use backslashes, consider using\nSarathy's File::DosGlob, which comes with the standard Perl distribution.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "\"glob\" in perlfunc, glob(3)\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "The Perl interface was written by Nathan Torkington <gnat@frii.com>, and is released under the\nartistic license. Further modifications were made by Greg Bacon <gbacon@cs.uah.edu>, Gurusamy\nSarathy <gsar@activestate.com>, and Thomas Wegner <wegnerthomas@yahoo.com>. The C glob code has\nthe following copyright:\n\nCopyright (c) 1989, 1993 The Regents of the University of California. All rights reserved.\n\nThis code is derived from software contributed to Berkeley by Guido van Rossum.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted\nprovided that the following conditions are met:\n\n1.  Redistributions of source code must retain the above copyright notice, this list of\nconditions and the following disclaimer.\n\n2.  Redistributions in binary form must reproduce the above copyright notice, this list of\nconditions and the following disclaimer in the documentation and/or other materials provided\nwith the distribution.\n\n3.  Neither the name of the University nor the names of its contributors may be used to endorse\nor promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\nFOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\nBUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\nOR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\nSTRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",
            "subsections": []
        }
    },
    "summary": "File::Glob - Perl extension for BSD glob routine",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "glob",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/glob/3/json"
        }
    ]
}