File::DosGlob(3perl)

πŸ’– File::DosGlob β€” DOS like globbing and then some πŸ’–

okay bestie, so this is File::DosGlob, a lil Perl module from the Perl Programmers Reference Guide, and it's giving "MS-DOS called, it wants its wildcards back" but like... in a good way? It does DOS-like globbing and honestly? then some. πŸŽ€


✨ SYNOPSIS ✨

    require 5.004;

    # override CORE::glob in current package
    use File::DosGlob 'glob';

    # override CORE::glob in ALL packages (use with extreme caution!)
    use File::DosGlob 'GLOBAL_glob';

    @perlfiles = glob  "..\\pe?l/*.p?";
    print <..\\pe?l/*.p?>;

    # from the command line (overrides only in main::)
    > perl -MFile::DosGlob=glob -e "print <../pe*/*p?>"

no cap, that's the whole vibe in nine-ish lines 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

So this module implements DOS-like globbing with a few little glow-ups on top. It's largely compatible with perlglob.exe (specifically the setargv.obj version, the M$ one πŸ’€) in all but one respect β€” and that respect is iconic: it actually understands wildcards in directory components. periodt.

For example, "<..\\l*b\\file/*glob.p?>" will work exactly as expected β€” as in, it'll genuinely find something like '..\lib\File/DosGlob.pm' alright. Obsessed.

Some things to know, lowkey important:

  • All path components are case-insensitive. she does not care about your capitalization.
  • Both backslashes and forward slashes are accepted, and preserved. ✨
  • You may have to double the backslashes if you're putting them in literally, because perl does that double-quotish parsing thing on the pattern. iykyk.

Spaces in the argument delimit distinct patterns, so glob('*.exe *.dll') globs all filenames that end in .exe or .dll. two for one, we love that. πŸ’…

But hmm, what if you want literal spaces in the glob pattern? You can escape them with either double quotes or backslashes. Like:

glob('c:/"Program Files"/*/*.dll')

or

glob('c:/Program\ Files/*/*.dll')

The argument gets tokenized using Text::ParseWords::parse_line(), so if you wanna know the full tea on quoting rules, go read Text::ParseWords. πŸ“–

Also, extending it to csh patterns is left as an exercise to the reader. ma'am that's homework and I'm not doing it πŸ™ˆ


🌸 EXPORTS (by request only) 🌸

  • glob()

that's it. one (1) single export, and only if you ask nicely. 🫢


πŸ’€ BUGS πŸ’€

ngl bestie, this thing should probably be built into the core, and it needs to stop pandering to DOS habits. it also needs a dose of optimization too. so like... it works! but she's a little unserious. 😭


πŸ‘‘ AUTHOR πŸ‘‘

Gurusamy Sarathy <gsar@activestate.com>


🌈 HISTORY 🌈

  1. Support for globally overriding glob() (GSAR 3-JUN-98)
  2. Scalar context, independent iterator context fixes (GSAR 15-SEP-97)
  3. A few dir-vs-file optimizations result in glob importation being 10 times faster than using perlglob.exe, and using perlglob.bat is only twice as slow as perlglob.exe (GSAR 28-MAY-97)
  4. Several cleanups prompted by lack of compatible perlglob.exe under Borland (GSAR 27-MAY-97)
  5. Initial version (GSAR 20-FEB-97)

the way this module has been evolving since 1997 and is still serving... a legend fr fr 🧚


πŸ”₯ SEE ALSO πŸ”₯

  • perl
  • perlglob.bat
  • Text::ParseWords

okay that's the whole page, bestie, go forth and glob ✨

perl v5.44.0 β€’ 2026-10-17 β€’ File::DosGlob(3perl) β€” mwah, thanks for reading, ily, drink water πŸ’–πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms