7 glob - Expand shell-wildcard patterns
11 glob [I<OPTIONS>] [--] I<PATTERN> [I<PATTERN> [I<PATTERN> [...]]]
15 Expand I<PATTERN> as shell-wildcard patterns and output matching filenames.
16 Output all matched file names once and sorted alphabetically.
24 Output filenames as NULL byte temrinated strings.
28 Fail if can not read a directory.
29 See B<GLOB_ERR> in File::Glob(3perl).
33 Match case-insensitively.
34 Default is case-sensitive.
38 Support curly bracket expansion.
39 See B<GLOB_BRACE> in File::Glob(3perl).
45 Uses perl(1)'s B<bsd_glob> function from File::Glob(3perl),
49 File::Glob(3perl), perldoc(1): glob
55 use Getopt
::Long qw
/:config no_ignore_case no_bundling no_getopt_compat no_auto_abbrev require_order/;
57 use File
::Glob
':bsd_glob';
58 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
60 $OptNullTerminated = 0;
61 $OptGlobFlags = GLOB_QUOTE
| GLOB_TILDE
;
64 '0' => \
$OptNullTerminated,
65 'f' => sub { $OptGlobFlags |= GLOB_ERR
; },
66 'i' => sub { $OptGlobFlags |= GLOB_NOCASE
; },
67 'b' => sub { $OptGlobFlags |= GLOB_BRACE
; },
68 'help' => sub { pod2usage
(-exitval
=>0, -verbose
=>99); },
69 '<>' => sub { unshift @ARGV, @_[0]; die '!FINISH'; },
70 ) or pod2usage
(-exitval
=>2, -verbose
=>99);
75 for my $pattern (@ARGV)
77 my @matches = bsd_glob
($pattern, $OptGlobFlags);
80 die "$0: $!: $pattern\n";
82 %Files = (%Files, map {$_=>1} @matches);
86 $\
= chr 0 if $OptNullTerminated;
87 print "$_" for sort keys %Files;