New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
glob() with spaces - documentation unclear #9393
Comments
From @epaCreated by @epause warnings; This unexpectedly matches every file in the current directory but I Now, if you read perlfunc(1) it has a note saying 'starting in 5.6... But this is obscure. The special treatment of space characters should Ideally, a space character in the pattern passed to glob() would be a Perl Info
|
From @pjfG'day Ed / p5p, Ed Avis (via RT) wrote:
I agree! I've attached a git-ish patch that adds to the documentation.
I disagree here, since I use glob splitting on spaces as a feature. I Cheerio, Paul -- |
From @pjf0001-Expanded-glob-documentation-with-whitespace-behaviou.patchFrom a527815a4fc7d6d858bf4e8e06ebff7696b76c88 Mon Sep 17 00:00:00 2001
From: Paul Fenwick <pjf@perltraining.com.au>
Date: Thu, 26 Jun 2008 11:39:59 +1000
Subject: [PATCH] Expanded glob documentation with whitespace behaviour.
* Mentions glob splits on whitespace.
* Provided some examples.
* Mentioned bsd_glob as an alternative.
---
pod/perlfunc.pod | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 864699d..5dafe1a 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -2348,8 +2348,14 @@ implementing the C<< <*.c> >> operator, but you can use it directly. If
EXPR is omitted, C<$_> is used. The C<< <*.c> >> operator is discussed in
more detail in L<perlop/"I/O Operators">.
+Note that C<glob> will split its arguments on whitespace, treating
+each segment as separate pattern. As such, C<glob('*.c *.h')> would
+match all files with a F<.c> or F<.h> extension. The expression
+C<glob('.* *')> would match all files in the current working directory.
+
Beginning with v5.6.0, this operator is implemented using the standard
-C<File::Glob> extension. See L<File::Glob> for details.
+C<File::Glob> extension. See L<File::Glob> for details, including
+C<bsd_glob> which does not treat whitespace as a pattern separator.
=item gmtime EXPR
X<gmtime> X<UTC> X<Greenwich>
--
1.5.2.2
|
The RT System itself - Status changed from 'new' to 'open' |
From ben@morrow.me.ukQuoth pjf@perltraining.com.au (Paul Fenwick):
Since it recently came up on clpmisc :), it's probably worth mentioning Ben -- |
From @rgs2008/6/26 Paul Fenwick <pjf@perltraining.com.au>:
Thanks, applied. |
From @pjfG'day Ben, Ben Morrow wrote:
I did try to allude to that in my patch, with the example of glob(".* *")
"What would csh do?"
Any wording suggestions? ;) Cheerio, Paul -- |
From @TuxOn Thu, 26 Jun 2008 18:17:46 +1000, Paul Fenwick
$ touch foo.c baar.o "foo bar.o" There is nothing more to it than that
-- |
From @pjfH.Merijn Brand wrote:
Sorry, that was a poor attempt at humour on my behalf, alluding to the "What Having said that, given that *, ?, [a-z], and {foo,bar,baz} all seem to work Cheerio, Paul -- |
From @TuxOn Thu, 26 Jun 2008 20:26:52 +1000, Paul Fenwick
% ls %.{c,o} -- |
From @epaThanks for fixing the doc. As for glob('*.c *.h'), this convenience could be given just as well by glob('*.c', '*.h') or if you prefer glob(qw(*.c *.h)) At least then perl can know you really wanted two separate patterns and Perl programs do tend to suffer bugs in handling filenames with spaces |
From @cpansproutOn Thu Jul 03 08:47:45 2008, ed wrote:
While I’d like to make File::Glob’s new :bsd_glob export make glob() If we can change that with perl 5.16, I’ll go head and make :bsd_glob I’m going to mark this as resolved, since the glob documentation in -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#56348 (status was 'resolved')
Searchable as RT56348$
The text was updated successfully, but these errors were encountered: