File::Zglob3pm
Extended globs.
Usage
use File::Zglob;my @files = zglob('**/*.{pm,pl}');
Overview
WARNINGS: THIS IS ALPHA VERSION. API MAY CHANGE WITHOUT NOTICE
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.
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/*.hsrc/*/*.hsrc/*/*/*.hsrc/*/*/*/*.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"
zglob and deep recursion
"**/*" form makes deep recursion by soft link. zglob throw exception if it's deep recursion.
Portability
- Win32
-
Zglob supports Win32.
zglob()only uses '/' as a path separator. Sincezglob()accepts non-utf8 strings. CP932 contains '\' character as a second byte of multibyte chars.
Limitations
- File order is not compatible with shells.
Thanks to
Most code was translated from gauche's fileutil.scm.
glob_to_regex function is taken from Text::Glob.
Releases
6 releases since Debian 8 (Jessie); the text changed 2 times.