summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-08-07 21:51:52 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-08-07 21:51:52 +0000
commit3eb19bc1ee971284bdbbbfec12098f835d4228e7 (patch)
tree8d3dcc4087e8a98e76d5b8cc58935436e7dc37c7 /lib
parent075282bacae016c5d1b367beb8dc3ecd2f9d2369 (diff)
downloadperl-3eb19bc1ee971284bdbbbfec12098f835d4228e7.tar.gz
allow more compatible interpretation of spaces File::DosGlob::glob()
patterns p4raw-id: //depot/maint-5.005/perl@1750
Diffstat (limited to 'lib')
-rw-r--r--lib/File/DosGlob.pm23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/File/DosGlob.pm b/lib/File/DosGlob.pm
index 24b28b2dce..594ee2ec84 100644
--- a/lib/File/DosGlob.pm
+++ b/lib/File/DosGlob.pm
@@ -97,17 +97,27 @@ my %entries;
sub glob {
my $pat = shift;
my $cxix = shift;
+ my @pat;
# glob without args defaults to $_
$pat = $_ unless defined $pat;
+ # extract patterns
+ if ($pat =~ /\s/) {
+ require Text::ParseWords;
+ @pat = Text::ParseWords::parse_line('\s+',0,$pat);
+ }
+ else {
+ push @pat, $pat;
+ }
+
# assume global context if not provided one
$cxix = '_G_' unless defined $cxix;
$iter{$cxix} = 0 unless exists $iter{$cxix};
# if we're just beginning, do it all first
if ($iter{$cxix} == 0) {
- $entries{$cxix} = [doglob(1,$pat)];
+ $entries{$cxix} = [doglob(1,@pat)];
}
# chuck it all out, quick or slow
@@ -174,6 +184,15 @@ backslashes and forward slashes are both accepted, and preserved.
You may have to double the backslashes if you are putting them in
literally, due to double-quotish parsing of the pattern by perl.
+Spaces in the argument delimit distinct patterns, so
+C<glob('*.exe *.dll')> globs all filenames that end in C<.exe>
+or C<.dll>. If you want to put in literal spaces in the glob
+pattern, you can escape them with either double quotes, or backslashes.
+e.g. C<glob('c:/"Program Files"/*/*.dll')>, or
+C<glob('c:/Program\ Files/*/*.dll')>. The argument is tokenized using
+C<Text::ParseWords::parse_line()>, so see L<Text::ParseWords> for details
+of the quoting rules used.
+
Extending it to csh patterns is left as an exercise to the reader.
=head1 EXPORTS (by request only)
@@ -224,5 +243,7 @@ perl
perlglob.bat
+Text::ParseWords
+
=cut