SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from OpenSuSE perl-Perlito5-9.028-lp156.4.1.noarch.rpm

Perlito5X::Java::File::Glob

Section: User Contributed Perl Documentation (3)
Updated: 2024-12-05
Index 

NAME

File::Glob - Perl extension for BSD glob routine 

SYNOPSIS

  use File::Glob ':bsd_glob';  @list = bsd_glob('*.[ch]');  $homedir = bsd_glob('~gnat', GLOB_TILDE | GLOB_ERR);  if (GLOB_ERROR) {    # an error occurred reading $homedir  }  ## override the core glob (CORE::glob() does this automatically  ## by default anyway, since v5.6.0)  use File::Glob ':globally';  my @sources = <*.{c,h,y}>;  ## override the core glob, forcing case sensitivity  use File::Glob qw(:globally :case);  my @sources = <*.{c,h,y}>;  ## override the core glob forcing case insensitivity  use File::Glob qw(:globally :nocase);  my @sources = <*.{c,h,y}>;  ## glob on all files in home directory  use File::Glob ':globally';  my @sources = <~gnat/*>;
 

DESCRIPTION

The glob angle-bracket operator "<>" is a pathname generator thatimplements the rules for file name pattern matching used by Unix-like shellssuch as the Bourne shell or C shell.

File::Glob::bsd_glob() implements the FreeBSD glob(3) routine, which isa superset of the POSIX glob() (described in IEEE Std 1003.2 ``POSIX.2'').bsd_glob() takes a mandatory "pattern" argument, and an optional"flags" argument, and returns a list of filenames matching thepattern, with interpretation of the pattern modified by the "flags"variable.

Since v5.6.0, Perl's CORE::glob() is implemented in terms of bsd_glob().Note that they don't share the same prototype---CORE::glob() only acceptsa single argument. Due to historical reasons, CORE::glob() will alsosplit its argument on whitespace, treating it as multiple patterns,whereas bsd_glob() considers them as one pattern. But see ":bsd_glob"under ``EXPORTS'', below. 

META CHARACTERS

  \       Quote the next metacharacter  []      Character class  {}      Multiple pattern  *       Match any string of characters  ?       Match any single character  ~       User name home directory

The metanotation "a{b,c,d}e" is a shorthand for "abe ace ade". Left toright order is preserved, with results of matches being sorted separatelyat a low level to preserve this order. As a special case "{", "}", and"{}" are passed undisturbed. 

EXPORTS

See also the ``POSIX FLAGS'' below, which can be exported individually.

":bsd_glob"

The ":bsd_glob" export tag exports bsd_glob() and the constants listedbelow. It also overrides glob() in the calling package with one thatbehaves like bsd_glob() with regard to spaces (the space is treated as partof a file name), but supports iteration in scalar context; i.e., itpreserves the core function's feature of returning the next item each timeit is called.

":glob"

The ":glob" tag, now discouraged, is the old version of ":bsd_glob". Itexports the same constants and functions, but its glob() override does notsupport iteration; it returns the last file name in scalar context. Thatmeans this will loop forever:

    use File::Glob ':glob';    while (my $file = <* copy.txt>) {        ...    }

"bsd_glob"

This function, which is included in the two export tags listed above,takes one or two arguments. The first is the glob pattern. Thesecond, if given, is a set of flags ORed together. The availableflags and the default set of flags are listed below under ``POSIX FLAGS''.

Remember that to use the named constants for flags you must importthem, for example with ":bsd_glob" described above. If not imported,and "use strict" is not in effect, then the constants will betreated as bareword strings, which won't do what you what.

":nocase" and ":case"

These two export tags globally modify the default flags that bsd_glob()and, except on VMS, Perl's built-in "glob" operator use. "GLOB_NOCASE"is turned on or off, respectively.

"csh_glob"

The csh_glob() function can also be exported, but you should not use itdirectly unless you really know what you are doing. It splits the patterninto words and feeds each one to bsd_glob(). Perl's own glob() functionuses this internally. 

POSIX FLAGS

If no flags argument is give then "GLOB_CSH" is set, and on VMS andWindows systems, "GLOB_NOCASE" too. Otherwise the flags to use aredetermined solely by the flags argument. The POSIX defined flags are:
"GLOB_ERR"
Force bsd_glob() to return an error when it encounters a directory itcannot open or read. Ordinarily bsd_glob() continues to find matches.
"GLOB_LIMIT"
Make bsd_glob() return an error (GLOB_NOSPACE) when the pattern expandsto a size bigger than the system constant "ARG_MAX" (usually found inlimits.h). If your system does not define this constant, bsd_glob() uses"sysconf(_SC_ARG_MAX)" or "_POSIX_ARG_MAX" where available (in thatorder). You can inspect these values using the standard "POSIX"extension.
"GLOB_MARK"
Each pathname that is a directory that matches the pattern has a slashappended.
"GLOB_NOCASE"
By default, file names are assumed to be case sensitive; this flagmakes bsd_glob() treat case differences as not significant.
"GLOB_NOCHECK"
If the pattern does not match any pathname, then bsd_glob() returns a listconsisting of only the pattern. If "GLOB_QUOTE" is set, its effectis present in the pattern returned.
"GLOB_NOSORT"
By default, the pathnames are sorted in ascending ASCII order; thisflag prevents that sorting (speeding up bsd_glob()).

The FreeBSD extensions to the POSIX standard are the following flags:

"GLOB_BRACE"
Pre-process the string to expand "{pat,pat,...}" strings like csh(1).The pattern '{}' is left unexpanded for historical reasons (and csh(1)does the same thing to ease typing of find(1) patterns).
"GLOB_NOMAGIC"
Same as "GLOB_NOCHECK" but it only returns the pattern if it does notcontain any of the special characters ``*'', ``?'' or ``[''. "NOMAGIC" isprovided to simplify implementing the historic csh(1) globbingbehaviour and should probably not be used anywhere else.
"GLOB_QUOTE"
Use the backslash ('\') character for quoting: every occurrence of abackslash followed by a character in the pattern is replaced by thatcharacter, avoiding any special interpretation of the character.(But see below for exceptions on DOSISH systems).
"GLOB_TILDE"
Expand patterns that start with '~' to user name home directories.
"GLOB_CSH"
For convenience, "GLOB_CSH" is a synonym for"GLOB_BRACE | GLOB_NOMAGIC | GLOB_QUOTE | GLOB_TILDE | GLOB_ALPHASORT".

The POSIX provided "GLOB_APPEND", "GLOB_DOOFFS", and the FreeBSDextensions "GLOB_ALTDIRFUNC", and "GLOB_MAGCHAR" flags have not beenimplemented in the Perl version because they involve more complexinteraction with the underlying C structures.

The following flag has been added in the Perl implementation forcsh compatibility:

"GLOB_ALPHASORT"
If "GLOB_NOSORT" is not in effect, sort filenames is alphabeticalorder (case does not matter) rather than in ASCII order.
 

DIAGNOSTICS

bsd_glob() returns a list of matching paths, possibly zero length. If anerror occurred, &File::Glob::GLOB_ERROR will be non-zero and $! will beset. &File::Glob::GLOB_ERROR is guaranteed to be zero if no error occurred,or one of the following values otherwise:
"GLOB_NOSPACE"
An attempt to allocate memory failed.
"GLOB_ABEND"
The glob was stopped because an error was encountered.

In the case where bsd_glob() has found some matching paths, but isinterrupted by an error, it will return a list of filenames andset &File::Glob::ERROR.

Note that bsd_glob() deviates from POSIX and FreeBSD glob(3) behaviourby not considering "ENOENT" and "ENOTDIR" as errors - bsd_glob() willcontinue processing despite those errors, unless the "GLOB_ERR" flag isset.

Be aware that all filenames returned from File::Glob are tainted. 

NOTES

If you want to use multiple patterns, e.g. "bsd_glob("a* b*")", you shouldprobably throw them in a set as in "bsd_glob("{a*,b*}")". This is becausethe argument to bsd_glob() isn't subjected to parsing by the C shell.Remember that you can use a backslash to escape things.
On DOSISH systems, backslash is a valid directory separator character.In this case, use of backslash as a quoting character (via GLOB_QUOTE)interferes with the use of backslash as a directory separator. Thebest (simplest, most portable) solution is to use forward slashes fordirectory separators, and backslashes for quoting. However, this doesnot match ``normal practice'' on these systems. As a concession to userexpectation, therefore, backslashes (under GLOB_QUOTE) only quote theglob metacharacters '[', ']', '{', '}', '-', '~', and backslash itself.All other backslashes are passed through unchanged.
Win32 users should use the real slash. If you really want to usebackslashes, consider using Sarathy's File::DosGlob, which comes withthe standard Perl distribution.
 

SEE ALSO

``glob'' in perlfunc, glob(3) 

AUTHOR

The Perl interface was written by Nathan Torkington <gnatAATTfrii.com>,and is released under the artistic license. Further modifications weremade by Greg Bacon <gbaconAATTcs.uah.edu>, Gurusamy Sarathy<gsarAATTactivestate.com>, and Thomas Wegner<wegner_thomasAATTyahoo.com>. The C glob code has thefollowing copyright:

Copyright (c) 1989, 1993 The Regents of the University of California.All rights reserved.

This code is derived from software contributed to Berkeley byGuido van Rossum.

Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met:

1.
Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.
2.
Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.
3.
Neither the name of the University nor the names of its contributorsmay be used to endorse or promote products derived from this softwarewithout specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLEFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODSOR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAYOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OFSUCH DAMAGE.


 

Index

NAME
SYNOPSIS
DESCRIPTION
META CHARACTERS
EXPORTS
POSIX FLAGS
DIAGNOSTICS
NOTES
SEE ALSO
AUTHOR

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector