1*0Sstevel@tonic-gatepackage File::Glob; 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateuse strict; 4*0Sstevel@tonic-gateour($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, 5*0Sstevel@tonic-gate $AUTOLOAD, $DEFAULT_FLAGS); 6*0Sstevel@tonic-gate 7*0Sstevel@tonic-gateuse XSLoader (); 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gate@ISA = qw(Exporter); 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gate# NOTE: The glob() export is only here for compatibility with 5.6.0. 12*0Sstevel@tonic-gate# csh_glob() should not be used directly, unless you know what you're doing. 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gate@EXPORT_OK = qw( 15*0Sstevel@tonic-gate csh_glob 16*0Sstevel@tonic-gate bsd_glob 17*0Sstevel@tonic-gate glob 18*0Sstevel@tonic-gate GLOB_ABEND 19*0Sstevel@tonic-gate GLOB_ALPHASORT 20*0Sstevel@tonic-gate GLOB_ALTDIRFUNC 21*0Sstevel@tonic-gate GLOB_BRACE 22*0Sstevel@tonic-gate GLOB_CSH 23*0Sstevel@tonic-gate GLOB_ERR 24*0Sstevel@tonic-gate GLOB_ERROR 25*0Sstevel@tonic-gate GLOB_LIMIT 26*0Sstevel@tonic-gate GLOB_MARK 27*0Sstevel@tonic-gate GLOB_NOCASE 28*0Sstevel@tonic-gate GLOB_NOCHECK 29*0Sstevel@tonic-gate GLOB_NOMAGIC 30*0Sstevel@tonic-gate GLOB_NOSORT 31*0Sstevel@tonic-gate GLOB_NOSPACE 32*0Sstevel@tonic-gate GLOB_QUOTE 33*0Sstevel@tonic-gate GLOB_TILDE 34*0Sstevel@tonic-gate); 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate%EXPORT_TAGS = ( 37*0Sstevel@tonic-gate 'glob' => [ qw( 38*0Sstevel@tonic-gate GLOB_ABEND 39*0Sstevel@tonic-gate GLOB_ALPHASORT 40*0Sstevel@tonic-gate GLOB_ALTDIRFUNC 41*0Sstevel@tonic-gate GLOB_BRACE 42*0Sstevel@tonic-gate GLOB_CSH 43*0Sstevel@tonic-gate GLOB_ERR 44*0Sstevel@tonic-gate GLOB_ERROR 45*0Sstevel@tonic-gate GLOB_LIMIT 46*0Sstevel@tonic-gate GLOB_MARK 47*0Sstevel@tonic-gate GLOB_NOCASE 48*0Sstevel@tonic-gate GLOB_NOCHECK 49*0Sstevel@tonic-gate GLOB_NOMAGIC 50*0Sstevel@tonic-gate GLOB_NOSORT 51*0Sstevel@tonic-gate GLOB_NOSPACE 52*0Sstevel@tonic-gate GLOB_QUOTE 53*0Sstevel@tonic-gate GLOB_TILDE 54*0Sstevel@tonic-gate glob 55*0Sstevel@tonic-gate bsd_glob 56*0Sstevel@tonic-gate ) ], 57*0Sstevel@tonic-gate); 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate$VERSION = '1.02'; 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gatesub import { 62*0Sstevel@tonic-gate require Exporter; 63*0Sstevel@tonic-gate my $i = 1; 64*0Sstevel@tonic-gate while ($i < @_) { 65*0Sstevel@tonic-gate if ($_[$i] =~ /^:(case|nocase|globally)$/) { 66*0Sstevel@tonic-gate splice(@_, $i, 1); 67*0Sstevel@tonic-gate $DEFAULT_FLAGS &= ~GLOB_NOCASE() if $1 eq 'case'; 68*0Sstevel@tonic-gate $DEFAULT_FLAGS |= GLOB_NOCASE() if $1 eq 'nocase'; 69*0Sstevel@tonic-gate if ($1 eq 'globally') { 70*0Sstevel@tonic-gate local $^W; 71*0Sstevel@tonic-gate *CORE::GLOBAL::glob = \&File::Glob::csh_glob; 72*0Sstevel@tonic-gate } 73*0Sstevel@tonic-gate next; 74*0Sstevel@tonic-gate } 75*0Sstevel@tonic-gate ++$i; 76*0Sstevel@tonic-gate } 77*0Sstevel@tonic-gate goto &Exporter::import; 78*0Sstevel@tonic-gate} 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gatesub AUTOLOAD { 81*0Sstevel@tonic-gate # This AUTOLOAD is used to 'autoload' constants from the constant() 82*0Sstevel@tonic-gate # XS function. If a constant is not found then control is passed 83*0Sstevel@tonic-gate # to the AUTOLOAD in AutoLoader. 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate my $constname; 86*0Sstevel@tonic-gate ($constname = $AUTOLOAD) =~ s/.*:://; 87*0Sstevel@tonic-gate my ($error, $val) = constant($constname); 88*0Sstevel@tonic-gate if ($error) { 89*0Sstevel@tonic-gate require Carp; 90*0Sstevel@tonic-gate Carp::croak($error); 91*0Sstevel@tonic-gate } 92*0Sstevel@tonic-gate eval "sub $AUTOLOAD { $val }"; 93*0Sstevel@tonic-gate goto &$AUTOLOAD; 94*0Sstevel@tonic-gate} 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gateXSLoader::load 'File::Glob', $VERSION; 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate# Preloaded methods go here. 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gatesub GLOB_ERROR { 101*0Sstevel@tonic-gate return (constant('GLOB_ERROR'))[1]; 102*0Sstevel@tonic-gate} 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gatesub GLOB_CSH () { 105*0Sstevel@tonic-gate GLOB_BRACE() 106*0Sstevel@tonic-gate | GLOB_NOMAGIC() 107*0Sstevel@tonic-gate | GLOB_QUOTE() 108*0Sstevel@tonic-gate | GLOB_TILDE() 109*0Sstevel@tonic-gate | GLOB_ALPHASORT() 110*0Sstevel@tonic-gate} 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate$DEFAULT_FLAGS = GLOB_CSH(); 113*0Sstevel@tonic-gateif ($^O =~ /^(?:MSWin32|VMS|os2|dos|riscos|MacOS)$/) { 114*0Sstevel@tonic-gate $DEFAULT_FLAGS |= GLOB_NOCASE(); 115*0Sstevel@tonic-gate} 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate# Autoload methods go after =cut, and are processed by the autosplit program. 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gatesub bsd_glob { 120*0Sstevel@tonic-gate my ($pat,$flags) = @_; 121*0Sstevel@tonic-gate $flags = $DEFAULT_FLAGS if @_ < 2; 122*0Sstevel@tonic-gate return doglob($pat,$flags); 123*0Sstevel@tonic-gate} 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate# File::Glob::glob() is deprecated because its prototype is different from 126*0Sstevel@tonic-gate# CORE::glob() (use bsd_glob() instead) 127*0Sstevel@tonic-gatesub glob { 128*0Sstevel@tonic-gate splice @_, 1; # don't pass PL_glob_index as flags! 129*0Sstevel@tonic-gate goto &bsd_glob; 130*0Sstevel@tonic-gate} 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate## borrowed heavily from gsar's File::DosGlob 133*0Sstevel@tonic-gatemy %iter; 134*0Sstevel@tonic-gatemy %entries; 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gatesub csh_glob { 137*0Sstevel@tonic-gate my $pat = shift; 138*0Sstevel@tonic-gate my $cxix = shift; 139*0Sstevel@tonic-gate my @pat; 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate # glob without args defaults to $_ 142*0Sstevel@tonic-gate $pat = $_ unless defined $pat; 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate # extract patterns 145*0Sstevel@tonic-gate $pat =~ s/^\s+//; # Protect against empty elements in 146*0Sstevel@tonic-gate $pat =~ s/\s+$//; # things like < *.c> and <*.c >. 147*0Sstevel@tonic-gate # These alone shouldn't trigger ParseWords. 148*0Sstevel@tonic-gate if ($pat =~ /\s/) { 149*0Sstevel@tonic-gate # XXX this is needed for compatibility with the csh 150*0Sstevel@tonic-gate # implementation in Perl. Need to support a flag 151*0Sstevel@tonic-gate # to disable this behavior. 152*0Sstevel@tonic-gate require Text::ParseWords; 153*0Sstevel@tonic-gate @pat = Text::ParseWords::parse_line('\s+',0,$pat); 154*0Sstevel@tonic-gate } 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate # assume global context if not provided one 157*0Sstevel@tonic-gate $cxix = '_G_' unless defined $cxix; 158*0Sstevel@tonic-gate $iter{$cxix} = 0 unless exists $iter{$cxix}; 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate # if we're just beginning, do it all first 161*0Sstevel@tonic-gate if ($iter{$cxix} == 0) { 162*0Sstevel@tonic-gate if (@pat) { 163*0Sstevel@tonic-gate $entries{$cxix} = [ map { doglob($_, $DEFAULT_FLAGS) } @pat ]; 164*0Sstevel@tonic-gate } 165*0Sstevel@tonic-gate else { 166*0Sstevel@tonic-gate $entries{$cxix} = [ doglob($pat, $DEFAULT_FLAGS) ]; 167*0Sstevel@tonic-gate } 168*0Sstevel@tonic-gate } 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate # chuck it all out, quick or slow 171*0Sstevel@tonic-gate if (wantarray) { 172*0Sstevel@tonic-gate delete $iter{$cxix}; 173*0Sstevel@tonic-gate return @{delete $entries{$cxix}}; 174*0Sstevel@tonic-gate } 175*0Sstevel@tonic-gate else { 176*0Sstevel@tonic-gate if ($iter{$cxix} = scalar @{$entries{$cxix}}) { 177*0Sstevel@tonic-gate return shift @{$entries{$cxix}}; 178*0Sstevel@tonic-gate } 179*0Sstevel@tonic-gate else { 180*0Sstevel@tonic-gate # return undef for EOL 181*0Sstevel@tonic-gate delete $iter{$cxix}; 182*0Sstevel@tonic-gate delete $entries{$cxix}; 183*0Sstevel@tonic-gate return undef; 184*0Sstevel@tonic-gate } 185*0Sstevel@tonic-gate } 186*0Sstevel@tonic-gate} 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate1; 189*0Sstevel@tonic-gate__END__ 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate=head1 NAME 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gateFile::Glob - Perl extension for BSD glob routine 194*0Sstevel@tonic-gate 195*0Sstevel@tonic-gate=head1 SYNOPSIS 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gate use File::Glob ':glob'; 198*0Sstevel@tonic-gate @list = bsd_glob('*.[ch]'); 199*0Sstevel@tonic-gate $homedir = bsd_glob('~gnat', GLOB_TILDE | GLOB_ERR); 200*0Sstevel@tonic-gate if (GLOB_ERROR) { 201*0Sstevel@tonic-gate # an error occurred reading $homedir 202*0Sstevel@tonic-gate } 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate ## override the core glob (CORE::glob() does this automatically 205*0Sstevel@tonic-gate ## by default anyway, since v5.6.0) 206*0Sstevel@tonic-gate use File::Glob ':globally'; 207*0Sstevel@tonic-gate my @sources = <*.{c,h,y}> 208*0Sstevel@tonic-gate 209*0Sstevel@tonic-gate ## override the core glob, forcing case sensitivity 210*0Sstevel@tonic-gate use File::Glob qw(:globally :case); 211*0Sstevel@tonic-gate my @sources = <*.{c,h,y}> 212*0Sstevel@tonic-gate 213*0Sstevel@tonic-gate ## override the core glob forcing case insensitivity 214*0Sstevel@tonic-gate use File::Glob qw(:globally :nocase); 215*0Sstevel@tonic-gate my @sources = <*.{c,h,y}> 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate=head1 DESCRIPTION 218*0Sstevel@tonic-gate 219*0Sstevel@tonic-gateFile::Glob::bsd_glob() implements the FreeBSD glob(3) routine, which is 220*0Sstevel@tonic-gatea superset of the POSIX glob() (described in IEEE Std 1003.2 "POSIX.2"). 221*0Sstevel@tonic-gatebsd_glob() takes a mandatory C<pattern> argument, and an optional 222*0Sstevel@tonic-gateC<flags> argument, and returns a list of filenames matching the 223*0Sstevel@tonic-gatepattern, with interpretation of the pattern modified by the C<flags> 224*0Sstevel@tonic-gatevariable. 225*0Sstevel@tonic-gate 226*0Sstevel@tonic-gateSince v5.6.0, Perl's CORE::glob() is implemented in terms of bsd_glob(). 227*0Sstevel@tonic-gateNote that they don't share the same prototype--CORE::glob() only accepts 228*0Sstevel@tonic-gatea single argument. Due to historical reasons, CORE::glob() will also 229*0Sstevel@tonic-gatesplit its argument on whitespace, treating it as multiple patterns, 230*0Sstevel@tonic-gatewhereas bsd_glob() considers them as one pattern. 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gateThe POSIX defined flags for bsd_glob() are: 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate=over 4 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate=item C<GLOB_ERR> 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gateForce bsd_glob() to return an error when it encounters a directory it 239*0Sstevel@tonic-gatecannot open or read. Ordinarily bsd_glob() continues to find matches. 240*0Sstevel@tonic-gate 241*0Sstevel@tonic-gate=item C<GLOB_LIMIT> 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gateMake bsd_glob() return an error (GLOB_NOSPACE) when the pattern expands 244*0Sstevel@tonic-gateto a size bigger than the system constant C<ARG_MAX> (usually found in 245*0Sstevel@tonic-gatelimits.h). If your system does not define this constant, bsd_glob() uses 246*0Sstevel@tonic-gateC<sysconf(_SC_ARG_MAX)> or C<_POSIX_ARG_MAX> where available (in that 247*0Sstevel@tonic-gateorder). You can inspect these values using the standard C<POSIX> 248*0Sstevel@tonic-gateextension. 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gate=item C<GLOB_MARK> 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gateEach pathname that is a directory that matches the pattern has a slash 253*0Sstevel@tonic-gateappended. 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gate=item C<GLOB_NOCASE> 256*0Sstevel@tonic-gate 257*0Sstevel@tonic-gateBy default, file names are assumed to be case sensitive; this flag 258*0Sstevel@tonic-gatemakes bsd_glob() treat case differences as not significant. 259*0Sstevel@tonic-gate 260*0Sstevel@tonic-gate=item C<GLOB_NOCHECK> 261*0Sstevel@tonic-gate 262*0Sstevel@tonic-gateIf the pattern does not match any pathname, then bsd_glob() returns a list 263*0Sstevel@tonic-gateconsisting of only the pattern. If C<GLOB_QUOTE> is set, its effect 264*0Sstevel@tonic-gateis present in the pattern returned. 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gate=item C<GLOB_NOSORT> 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gateBy default, the pathnames are sorted in ascending ASCII order; this 269*0Sstevel@tonic-gateflag prevents that sorting (speeding up bsd_glob()). 270*0Sstevel@tonic-gate 271*0Sstevel@tonic-gate=back 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gateThe FreeBSD extensions to the POSIX standard are the following flags: 274*0Sstevel@tonic-gate 275*0Sstevel@tonic-gate=over 4 276*0Sstevel@tonic-gate 277*0Sstevel@tonic-gate=item C<GLOB_BRACE> 278*0Sstevel@tonic-gate 279*0Sstevel@tonic-gatePre-process the string to expand C<{pat,pat,...}> strings like csh(1). 280*0Sstevel@tonic-gateThe pattern '{}' is left unexpanded for historical reasons (and csh(1) 281*0Sstevel@tonic-gatedoes the same thing to ease typing of find(1) patterns). 282*0Sstevel@tonic-gate 283*0Sstevel@tonic-gate=item C<GLOB_NOMAGIC> 284*0Sstevel@tonic-gate 285*0Sstevel@tonic-gateSame as C<GLOB_NOCHECK> but it only returns the pattern if it does not 286*0Sstevel@tonic-gatecontain any of the special characters "*", "?" or "[". C<NOMAGIC> is 287*0Sstevel@tonic-gateprovided to simplify implementing the historic csh(1) globbing 288*0Sstevel@tonic-gatebehaviour and should probably not be used anywhere else. 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate=item C<GLOB_QUOTE> 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gateUse the backslash ('\') character for quoting: every occurrence of a 293*0Sstevel@tonic-gatebackslash followed by a character in the pattern is replaced by that 294*0Sstevel@tonic-gatecharacter, avoiding any special interpretation of the character. 295*0Sstevel@tonic-gate(But see below for exceptions on DOSISH systems). 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate=item C<GLOB_TILDE> 298*0Sstevel@tonic-gate 299*0Sstevel@tonic-gateExpand patterns that start with '~' to user name home directories. 300*0Sstevel@tonic-gate 301*0Sstevel@tonic-gate=item C<GLOB_CSH> 302*0Sstevel@tonic-gate 303*0Sstevel@tonic-gateFor convenience, C<GLOB_CSH> is a synonym for 304*0Sstevel@tonic-gateC<GLOB_BRACE | GLOB_NOMAGIC | GLOB_QUOTE | GLOB_TILDE | GLOB_ALPHASORT>. 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate=back 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gateThe POSIX provided C<GLOB_APPEND>, C<GLOB_DOOFFS>, and the FreeBSD 309*0Sstevel@tonic-gateextensions C<GLOB_ALTDIRFUNC>, and C<GLOB_MAGCHAR> flags have not been 310*0Sstevel@tonic-gateimplemented in the Perl version because they involve more complex 311*0Sstevel@tonic-gateinteraction with the underlying C structures. 312*0Sstevel@tonic-gate 313*0Sstevel@tonic-gateThe following flag has been added in the Perl implementation for 314*0Sstevel@tonic-gatecsh compatibility: 315*0Sstevel@tonic-gate 316*0Sstevel@tonic-gate=over 4 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate=item C<GLOB_ALPHASORT> 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gateIf C<GLOB_NOSORT> is not in effect, sort filenames is alphabetical 321*0Sstevel@tonic-gateorder (case does not matter) rather than in ASCII order. 322*0Sstevel@tonic-gate 323*0Sstevel@tonic-gate=back 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate=head1 DIAGNOSTICS 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gatebsd_glob() returns a list of matching paths, possibly zero length. If an 328*0Sstevel@tonic-gateerror occurred, &File::Glob::GLOB_ERROR will be non-zero and C<$!> will be 329*0Sstevel@tonic-gateset. &File::Glob::GLOB_ERROR is guaranteed to be zero if no error occurred, 330*0Sstevel@tonic-gateor one of the following values otherwise: 331*0Sstevel@tonic-gate 332*0Sstevel@tonic-gate=over 4 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate=item C<GLOB_NOSPACE> 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gateAn attempt to allocate memory failed. 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gate=item C<GLOB_ABEND> 339*0Sstevel@tonic-gate 340*0Sstevel@tonic-gateThe glob was stopped because an error was encountered. 341*0Sstevel@tonic-gate 342*0Sstevel@tonic-gate=back 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gateIn the case where bsd_glob() has found some matching paths, but is 345*0Sstevel@tonic-gateinterrupted by an error, it will return a list of filenames B<and> 346*0Sstevel@tonic-gateset &File::Glob::ERROR. 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gateNote that bsd_glob() deviates from POSIX and FreeBSD glob(3) behaviour 349*0Sstevel@tonic-gateby not considering C<ENOENT> and C<ENOTDIR> as errors - bsd_glob() will 350*0Sstevel@tonic-gatecontinue processing despite those errors, unless the C<GLOB_ERR> flag is 351*0Sstevel@tonic-gateset. 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gateBe aware that all filenames returned from File::Glob are tainted. 354*0Sstevel@tonic-gate 355*0Sstevel@tonic-gate=head1 NOTES 356*0Sstevel@tonic-gate 357*0Sstevel@tonic-gate=over 4 358*0Sstevel@tonic-gate 359*0Sstevel@tonic-gate=item * 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gateIf you want to use multiple patterns, e.g. C<bsd_glob "a* b*">, you should 362*0Sstevel@tonic-gateprobably throw them in a set as in C<bsd_glob "{a*,b*}">. This is because 363*0Sstevel@tonic-gatethe argument to bsd_glob() isn't subjected to parsing by the C shell. 364*0Sstevel@tonic-gateRemember that you can use a backslash to escape things. 365*0Sstevel@tonic-gate 366*0Sstevel@tonic-gate=item * 367*0Sstevel@tonic-gate 368*0Sstevel@tonic-gateOn DOSISH systems, backslash is a valid directory separator character. 369*0Sstevel@tonic-gateIn this case, use of backslash as a quoting character (via GLOB_QUOTE) 370*0Sstevel@tonic-gateinterferes with the use of backslash as a directory separator. The 371*0Sstevel@tonic-gatebest (simplest, most portable) solution is to use forward slashes for 372*0Sstevel@tonic-gatedirectory separators, and backslashes for quoting. However, this does 373*0Sstevel@tonic-gatenot match "normal practice" on these systems. As a concession to user 374*0Sstevel@tonic-gateexpectation, therefore, backslashes (under GLOB_QUOTE) only quote the 375*0Sstevel@tonic-gateglob metacharacters '[', ']', '{', '}', '-', '~', and backslash itself. 376*0Sstevel@tonic-gateAll other backslashes are passed through unchanged. 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gate=item * 379*0Sstevel@tonic-gate 380*0Sstevel@tonic-gateWin32 users should use the real slash. If you really want to use 381*0Sstevel@tonic-gatebackslashes, consider using Sarathy's File::DosGlob, which comes with 382*0Sstevel@tonic-gatethe standard Perl distribution. 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate=item * 385*0Sstevel@tonic-gate 386*0Sstevel@tonic-gateMac OS (Classic) users should note a few differences. Since 387*0Sstevel@tonic-gateMac OS is not Unix, when the glob code encounters a tilde glob (e.g. 388*0Sstevel@tonic-gate~user) and the C<GLOB_TILDE> flag is used, it simply returns that 389*0Sstevel@tonic-gatepattern without doing any expansion. 390*0Sstevel@tonic-gate 391*0Sstevel@tonic-gateGlob on Mac OS is case-insensitive by default (if you don't use any 392*0Sstevel@tonic-gateflags). If you specify any flags at all and still want glob 393*0Sstevel@tonic-gateto be case-insensitive, you must include C<GLOB_NOCASE> in the flags. 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gateThe path separator is ':' (aka colon), not '/' (aka slash). Mac OS users 396*0Sstevel@tonic-gateshould be careful about specifying relative pathnames. While a full path 397*0Sstevel@tonic-gatealways begins with a volume name, a relative pathname should always 398*0Sstevel@tonic-gatebegin with a ':'. If specifying a volume name only, a trailing ':' is 399*0Sstevel@tonic-gaterequired. 400*0Sstevel@tonic-gate 401*0Sstevel@tonic-gateThe specification of pathnames in glob patterns adheres to the usual Mac 402*0Sstevel@tonic-gateOS conventions: The path separator is a colon ':', not a slash '/'. A 403*0Sstevel@tonic-gatefull path always begins with a volume name. A relative pathname on Mac 404*0Sstevel@tonic-gateOS must always begin with a ':', except when specifying a file or 405*0Sstevel@tonic-gatedirectory name in the current working directory, where the leading colon 406*0Sstevel@tonic-gateis optional. If specifying a volume name only, a trailing ':' is 407*0Sstevel@tonic-gaterequired. Due to these rules, a glob like E<lt>*:E<gt> will find all 408*0Sstevel@tonic-gatemounted volumes, while a glob like E<lt>*E<gt> or E<lt>:*E<gt> will find 409*0Sstevel@tonic-gateall files and directories in the current directory. 410*0Sstevel@tonic-gate 411*0Sstevel@tonic-gateNote that updirs in the glob pattern are resolved before the matching begins, 412*0Sstevel@tonic-gatei.e. a pattern like "*HD:t?p::a*" will be matched as "*HD:a*". Note also, 413*0Sstevel@tonic-gatethat a single trailing ':' in the pattern is ignored (unless it's a volume 414*0Sstevel@tonic-gatename pattern like "*HD:"), i.e. a glob like E<lt>:*:E<gt> will find both 415*0Sstevel@tonic-gatedirectories I<and> files (and not, as one might expect, only directories). 416*0Sstevel@tonic-gateYou can, however, use the C<GLOB_MARK> flag to distinguish (without a file 417*0Sstevel@tonic-gatetest) directory names from file names. 418*0Sstevel@tonic-gate 419*0Sstevel@tonic-gateIf the C<GLOB_MARK> flag is set, all directory paths will have a ':' appended. 420*0Sstevel@tonic-gateSince a directory like 'lib:' is I<not> a valid I<relative> path on Mac OS, 421*0Sstevel@tonic-gateboth a leading and a trailing colon will be added, when the directory name in 422*0Sstevel@tonic-gatequestion doesn't contain any colons (e.g. 'lib' becomes ':lib:'). 423*0Sstevel@tonic-gate 424*0Sstevel@tonic-gate=back 425*0Sstevel@tonic-gate 426*0Sstevel@tonic-gate=head1 AUTHOR 427*0Sstevel@tonic-gate 428*0Sstevel@tonic-gateThe Perl interface was written by Nathan Torkington E<lt>gnat@frii.comE<gt>, 429*0Sstevel@tonic-gateand is released under the artistic license. Further modifications were 430*0Sstevel@tonic-gatemade by Greg Bacon E<lt>gbacon@cs.uah.eduE<gt>, Gurusamy Sarathy 431*0Sstevel@tonic-gateE<lt>gsar@activestate.comE<gt>, and Thomas Wegner 432*0Sstevel@tonic-gateE<lt>wegner_thomas@yahoo.comE<gt>. The C glob code has the 433*0Sstevel@tonic-gatefollowing copyright: 434*0Sstevel@tonic-gate 435*0Sstevel@tonic-gate Copyright (c) 1989, 1993 The Regents of the University of California. 436*0Sstevel@tonic-gate All rights reserved. 437*0Sstevel@tonic-gate 438*0Sstevel@tonic-gate This code is derived from software contributed to Berkeley by 439*0Sstevel@tonic-gate Guido van Rossum. 440*0Sstevel@tonic-gate 441*0Sstevel@tonic-gate Redistribution and use in source and binary forms, with or without 442*0Sstevel@tonic-gate modification, are permitted provided that the following conditions 443*0Sstevel@tonic-gate are met: 444*0Sstevel@tonic-gate 445*0Sstevel@tonic-gate 1. Redistributions of source code must retain the above copyright 446*0Sstevel@tonic-gate notice, this list of conditions and the following disclaimer. 447*0Sstevel@tonic-gate 2. Redistributions in binary form must reproduce the above copyright 448*0Sstevel@tonic-gate notice, this list of conditions and the following disclaimer in the 449*0Sstevel@tonic-gate documentation and/or other materials provided with the distribution. 450*0Sstevel@tonic-gate 3. Neither the name of the University nor the names of its contributors 451*0Sstevel@tonic-gate may be used to endorse or promote products derived from this software 452*0Sstevel@tonic-gate without specific prior written permission. 453*0Sstevel@tonic-gate 454*0Sstevel@tonic-gate THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 455*0Sstevel@tonic-gate ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 456*0Sstevel@tonic-gate IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 457*0Sstevel@tonic-gate ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 458*0Sstevel@tonic-gate FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 459*0Sstevel@tonic-gate DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 460*0Sstevel@tonic-gate OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 461*0Sstevel@tonic-gate HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 462*0Sstevel@tonic-gate LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 463*0Sstevel@tonic-gate OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 464*0Sstevel@tonic-gate SUCH DAMAGE. 465*0Sstevel@tonic-gate 466*0Sstevel@tonic-gate=cut 467