File::DosGlob(3pm)

🌸 File::DosGlob πŸ’…

okay bestie, so this page? It's the manual for File::DosGlob β€” literally "DOS like globbing and then some" ✨ Like, DOS-style wildcard matching, but upgraded. Come sit, I'll tell you everything 🫢


✨ 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 second one is giving main character energy but also danger 😭 GLOBAL_glob touches ALL packages β€” the manual literally says use with extreme caution! πŸ’€ You've been warned, babe.


πŸ’– DESCRIPTION πŸ’–

So this module implements DOS-like globbing, with a few lil enhancements sprinkled on top πŸŽ€ It's largely compatible with perlglob.exe (the M$ setargv.obj version) in all but one respect β€” and that one respect is kind of the whole slay: it understands wildcards in directory components. πŸ‘‘

Like for example, <..\\l*b\\file/*glob.p?> will work as expected β€” in that it'll find something like '..\lib\File/DosGlob.pm' alright. Yes queen, wildcards inside the directory part. Obsessed. πŸ’…

Heads up bestie: all path components are case-insensitive, and both backslashes and forward slashes are accepted and preserved. Also you may have to double the backslashes if you're putting them in literally, because of perl's double-quotish parsing of the pattern. That's not me being dramatic, that's just how it is 🫠

Spaces in the argument delimit distinct patterns, so glob('*.exe *.dll') globs all filenames that end in ".exe" or ".dll" ✨ Two patterns, one call, we love efficiency.

But what if you want a literal space in your glob pattern? Bestie you can escape them β€” either with double quotes or with backslashes:

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

or

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

Both iconic, both valid πŸ’œ The argument is tokenized using Text::ParseWords::parse_line(), so see Text::ParseWords for details of the quoting rules used. (Yes, that's a real module, go read it, iykyk.)

Extending it to csh patterns is left as an exercise to the reader. 🧚 Like, the author literally handed you homework. Do with that what you will ✨


πŸŽ€ EXPORTS (by request only) πŸŽ€

  • glob() β€” that's it. That's the export. By request only, so don't come crying when it's not there automatically πŸ™ˆ

πŸ’€ BUGS πŸ’€

Not gonna sugarcoat it: it should probably be built into the core, and it needs to stop pandering to DOS habits. Also needs a dose of optimization too. The vibes are, uh, legacy 😭 but we respect the elders fr fr.


πŸ‘‘ AUTHOR πŸ‘‘

Gurusamy Sarathy <gsar@activestate.com> β€” thank you for your service 🫢


🌈 HISTORY 🌈

the lore, chronologically, king:

  • 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 using perlglob.bat is only twice as slow as perlglob.exe (GSAR 28-MAY-97) πŸ”₯
  • Several cleanups prompted by lack of compatible perlglob.exe under Borland (GSAR 27-MAY-97)
  • Initial version (GSAR 20-FEB-97) ⭐

πŸ¦‹ SEE ALSO πŸ¦‹

  • perl
  • perlglob.bat
  • Text::ParseWords

and that's the whole page, bestie πŸ’– this little number is perl v5.42.3, dated 2026-11-03 β€” go forth and glob responsibly 🌸🫢✨

πŸ“¦ where this page comes from