1File::DosGlob(3pm)     Perl Programmers Reference Guide     File::DosGlob(3pm)
2
3
4

NAME

6       File::DosGlob - DOS like globbing and then some
7

SYNOPSIS

9           require 5.004;
10
11           # override CORE::glob in current package
12           use File::DosGlob 'glob';
13
14           # override CORE::glob in ALL packages (use with extreme caution!)
15           use File::DosGlob 'GLOBAL_glob';
16
17           @perlfiles = glob  "..\\pe?l/*.p?";
18           print <..\\pe?l/*.p?>;
19
20           # from the command line (overrides only in main::)
21           > perl -MFile::DosGlob=glob -e "print <../pe*/*p?>"
22

DESCRIPTION

24       A module that implements DOS-like globbing with a few enhancements.  It
25       is largely compatible with perlglob.exe (the M$ setargv.obj version) in
26       all but one respect--it understands wildcards in directory components.
27
28       For example, "<..\\l*b\\file/*glob.p?"> will work as expected (in that
29       it will find something like '..\lib\File/DosGlob.pm' alright).  Note
30       that all path components are case-insensitive, and that backslashes and
31       forward slashes are both accepted, and preserved.  You may have to
32       double the backslashes if you are putting them in literally, due to
33       double-quotish parsing of the pattern by perl.
34
35       Spaces in the argument delimit distinct patterns, so "glob('*.exe
36       *.dll')" globs all filenames that end in ".exe" or ".dll".  If you want
37       to put in literal spaces in the glob pattern, you can escape them with
38       either double quotes, or backslashes.  e.g. "glob('c:/"Program
39       Files"/*/*.dll')", or "glob('c:/Program\ Files/*/*.dll')".  The
40       argument is tokenized using "Text::ParseWords::parse_line()", so see
41       Text::ParseWords for details of the quoting rules used.
42
43       Extending it to csh patterns is left as an exercise to the reader.
44

NOTES

46       ·   Mac OS (Classic) users should note a few differences. The
47           specification of pathnames in glob patterns adheres to the usual
48           Mac OS conventions: The path separator is a colon ':', not a slash
49           '/' or backslash '\'. A full path always begins with a volume name.
50           A relative pathname on Mac OS must always begin with a ':', except
51           when specifying a file or directory name in the current working
52           directory, where the leading colon is optional. If specifying a
53           volume name only, a trailing ':' is required. Due to these rules, a
54           glob like <*:> will find all mounted volumes, while a glob like <*>
55           or <:*> will find all files and directories in the current
56           directory.
57
58           Note that updirs in the glob pattern are resolved before the
59           matching begins, i.e. a pattern like "*HD:t?p::a*" will be matched
60           as "*HD:a*". Note also, that a single trailing ':' in the pattern
61           is ignored (unless it's a volume name pattern like "*HD:"), i.e. a
62           glob like <:*:> will find both directories and files (and not, as
63           one might expect, only directories).
64
65           The metachars '*', '?' and the escape char '\' are valid characters
66           in volume, directory and file names on Mac OS. Hence, if you want
67           to match a '*', '?' or '\' literally, you have to escape these
68           characters. Due to perl's quoting rules, things may get a bit
69           complicated, when you want to match a string like '\*' literally,
70           or when you want to match '\' literally, but treat the immediately
71           following character '*' as metachar. So, here's a rule of thumb
72           (applies to both single- and double-quoted strings): escape each
73           '*' or '?' or '\' with a backslash, if you want to treat them
74           literally, and then double each backslash and your are done. E.g.
75
76           - Match '\*' literally
77
78              escape both '\' and '*'  : '\\\*'
79              double the backslashes   : '\\\\\\*'
80
81           (Internally, the glob routine sees a '\\\*', which means that both
82           '\' and '*' are escaped.)
83
84           - Match '\' literally, treat '*' as metachar
85
86              escape '\' but not '*'   : '\\*'
87              double the backslashes   : '\\\\*'
88
89           (Internally, the glob routine sees a '\\*', which means that '\' is
90           escaped and '*' is not.)
91
92           Note that you also have to quote literal spaces in the glob
93           pattern, as described above.
94

EXPORTS (by request only)

96       glob()
97

BUGS

99       Should probably be built into the core, and needs to stop pandering to
100       DOS habits.  Needs a dose of optimizium too.
101

AUTHOR

103       Gurusamy Sarathy <gsar@activestate.com>
104

HISTORY

106       ·   Support for globally overriding glob() (GSAR 3-JUN-98)
107
108       ·   Scalar context, independent iterator context fixes (GSAR 15-SEP-97)
109
110       ·   A few dir-vs-file optimizations result in glob importation being 10
111           times faster than using perlglob.exe, and using perlglob.bat is
112           only twice as slow as perlglob.exe (GSAR 28-MAY-97)
113
114       ·   Several cleanups prompted by lack of compatible perlglob.exe under
115           Borland (GSAR 27-MAY-97)
116
117       ·   Initial version (GSAR 20-FEB-97)
118

SEE ALSO

120       perl
121
122       perlglob.bat
123
124       Text::ParseWords
125
126
127
128perl v5.12.4                      2011-06-07                File::DosGlob(3pm)
Impressum