csh_glob#
Expand a pattern using the default flag set - the engine behind Perl’s built-in glob.
Synopsis#
use File::Glob qw(csh_glob);
my @files = csh_glob('*.pl');
What you get back#
A list of matching filenames. Flags always come from $File::Glob::DEFAULT_FLAGS (initially GLOB_CSH); csh_glob takes no flag argument. Sort order, brace expansion, tilde expansion, and the rest follow whatever DEFAULT_FLAGS currently holds.
You almost certainly want bsd_glob or the angle-bracket operator <...> instead. csh_glob exists because Perl’s built-in glob dispatches through it; calling it directly is documented as “don’t unless you know what you’re doing.”
Examples#
use File::Glob qw(csh_glob);
my @matches = csh_glob('*.txt'); # uses DEFAULT_FLAGS
# Flip case sensitivity globally, then call
use File::Glob qw(csh_glob :nocase);
my @any = csh_glob('ReadMe*'); # matches README, readme, ReadMe, ...
Edge cases#
Called with no argument: the pattern comes from
$_, as it does for the built-inglob.The pattern is split on whitespace into several sub-patterns, so
csh_glob('*.c *.h')globs both. Quote a token, or usebsd_glob, when the pattern itself contains a space.A pattern containing an embedded NUL byte warns and returns the empty list.
Differences from upstream#
Fully compatible with upstream: patterns are tokenised on whitespace (honouring quotes and backslash escapes), and the per-op cache gives scalar context one name per call.
See also#
bsd_glob- the public, flag-accepting equivalent; prefer it.GLOB_CSH- the flag setDEFAULT_FLAGSis seeded with.:nocase/:case- import tags that toggleGLOB_NOCASEinDEFAULT_FLAGS.