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 arguments: returns the empty list.
Unlike upstream, does not split the pattern on whitespace into multiple sub-patterns; the whole string is treated as one pattern.
Does not maintain per-op iterator state, so it cannot be driven one-result-at-a-time in scalar context.
Differences from upstream#
No whitespace-splitting of patterns. Upstream
csh_globtokenises"a* b*"into two patterns; pperl treats it as a single literal pattern. Usebsd_glob('{a*,b*}')if you need multiple patterns in one call.No scalar-context iterator. The per-op result cache that lets upstream’s
while (my $f = <*.c>)yield one name per iteration is not implemented — scalar context returns the match count. Covered byt/81-xs-native/File/Glob/*.t.
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.