File::Zglob - Extended globs.
Contents
Description
WARNINGS:THISISALPHAVERSION.APIMAYCHANGEWITHOUTNOTICE
Provides a traditional Unix glob(3) functionality; returns a list of pathnames that matches the given
pattern.
File::Zglob provides extended glob. It supports "**/*.pm" form.
Functions
zglob($pattern) # => list of matched files
my @files = zglob('**/*.[ch]');
Unlike shell's glob, if there's no matching pathnames, () is returned.
License
Copyright (C) Tokuhiro Matsuno
This library is free software; you can redistribute it and/or modify it under the same terms as Perl
itself.
perl v5.38.2 2024-03-05 File::Zglob(3pm)
Limitations
File order is not compatible with shells.
Name
File::Zglob - Extended globs.
Portability
Win32
Zglob supports Win32. zglob() only uses '/' as a path separator. Since zglob() accepts non-utf8
strings. CP932 contains '\' character as a second byte of multibyte chars.
See Also
File::DosGlob, Text::Glob, gauche's fileutil.scm
Special Chars
A glob pattern also consists of components and separator characters. In a component, following
characters/syntax have special meanings.
"*" When it appears at the beginning of a component, it matches zero or more characters except a period
(.). And it won't match if the component of the input string begins with a period.
Otherwise, it matches zero or more sequence of any characters.
"**"
If a component is just **, it matches zero or more number of components that match *. For example,
src/**/*.h matches all of the following patterns.
src/*.h
src/*/*.h
src/*/*/*.h
src/*/*/*/*.h
...
"?" When it appears at the beginning of a component, it matches a character except a period (.).
Otherwise, it matches any single character.
"[chars]"
Specifies a character set. Matches any one of the set. The syntax of chars is the same as perl's
character set syntax.
"{pm,pl}"
There is alternation.
"example.{foo,bar,baz}" matches "example.foo", "example.bar", and "example.baz"
Synopsis
use File::Zglob;
my @files = zglob('**/*.{pm,pl}');
Thanks To
Most code was translated from gauche's fileutil.scm.
glob_to_regex function is taken from Text::Glob.
Zglob And Deep Recursion
"**/*" form makes deep recursion by soft link. zglob throw exception if it's deep recursion.
