File::Zglob(3pm) | User Contributed Perl Documentation | File::Zglob(3pm) |
NAME¶
File::Zglob - Extended globs.
SYNOPSIS¶
use File::Zglob; my @files = zglob('**/*.{pm,pl}');
DESCRIPTION¶
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/*.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"
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. Since zglob() accepts non-utf8 strings. CP932 contains '\' character as a second byte of multibyte chars.
LIMITATIONS¶
AUTHOR¶
Tokuhiro Matsuno <tokuhirom AAJKLFJEF GMAIL COM>
THANKS TO¶
Most code was translated from gauche's fileutil.scm.
glob_to_regex function is taken from Text::Glob.
SEE ALSO¶
File::DosGlob, Text::Glob, gauche's fileutil.scm
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.
2024-03-05 | perl v5.38.2 |