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 π
- Support for globally overriding
glob()(GSAR 3-JUN-98) - Scalar context, independent iterator context fixes (GSAR 15-SEP-97)
- A few dir-vs-file optimizations result in glob importation being 10 times faster than using
perlglob.exe, and usingperlglob.batis only twice as slow asperlglob.exe(GSAR 28-MAY-97) - Several cleanups prompted by lack of compatible
perlglob.exeunder Borland (GSAR 27-MAY-97) - 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 π₯
perlperlglob.batText::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