In list context, returns a (possibly empty) list of filename expansions on
the value of EXPR such as the standard Unix shell /bin/csh would do. In
scalar context, glob iterates through such filename expansions, returning
undef when the list is exhausted. This is the internal function
operator, but you can use it directly. If
EXPR is omitted, $_ is used. The
is discussed in more detail in I/O Operators in perlop.
Note that glob splits its arguments on whitespace and
each segment as separate pattern. As such,
matches all files with a .c or .h extension. The expression
matches all files in the current working directory.
If you want to glob filenames that might contain whitespace, you'll
have to use extra quotes around the spacey filename to protect it.
For example, to glob filenames that have an
followed by a space
followed by an
, use one of:
If you had to get a variable through, you could do this:
If non-empty braces are the only wildcard characters used in the glob, no filenames are matched, but potentially many strings are returned. For example, this produces nine strings, one for each pairing of fruits and colors:
Portability issues: glob in perlport.