File::DosGlob#
📦 std
A DOS-style glob, whose iterators live per call site.
use File::DosGlob 'glob'; # overrides glob() in this package
print join(" ", map { s{.*/}{}r } glob("$d/*.txt")), "\n"; # b.txt a.txt
while (my $f = glob("$d/*.log")) { print "log: $f\n" } # one iterator per call site
It understands DOS-style paths as well as Unix ones - drive letters, \ as a separator, spaces in names - and, unlike the built-in glob, returns names in directory order, unsorted. Importing glob replaces it in the importing package; use File::DosGlob 'GLOBAL_glob' replaces it everywhere.
This is a native implementation of the XS half of File::DosGlob 1.12: File/DosGlob.pm is used unchanged and does the globbing, keeping each call site’s iterator in %File::DosGlob::entries, keyed by the op that called glob. The XS half supplies that key, _callsite(), and an op-free hook that deletes an op’s entry when the op is freed, so a new op at the same address does not inherit it.
Differences from upstream#
None.