For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > September 2006 > Re: glob problem: escaped space seems to be significant too (was









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: glob problem: escaped space seems to be significant too (was
Mumia W. (reading news)

2006-09-27, 7:01 pm

On 09/27/2006 08:43 AM, David Squire wrote:
> David Squire wrote:
>
> Hi again,
>
> I have reduced this further, getting rid of de-url and a bunch of other
> stuff related to my original context. Please see the reduced script and
> output below. It seems that having an escaped space as well as an escape
> '[' causes the failure to match. See the third last test case.
>
> I hesitate to say it, but this begins to feel like a bug... (covers head).
>
> ----
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> print "Directory contents:\n", `ls -1 f*`, "\n";
> for my $GlobPattern (
> 'fred*',
> 'fred[1]*',
> 'fred\[1\]*',
> 'fred\[1]*',
> 'fred[1\]*',
> 'fre\ d*',
> 'fre\ d\[*',
> 'fre\ d\[1*',
> 'fre\ d\[1\]*',
> 'fre?d\[1\]*',
> 'fre\ d?1\]*',
> ) {
> my @CandidateOrigFiles = glob ($GlobPattern);
> print " \n######################################
\n";
> print "$GlobPattern: \@CandidateOrigFiles:\n", join "\n",
> @CandidateOrigFiles;
> }
>
> ----
>
> Output:
>
> Directory contents:
> fred]
> fred[1]
> fre d[1].doc
> fred[[1].doc
> fred[1].doc
>
>
> ######################################
> fred*: @CandidateOrigFiles:
> fred[1]
> fred[1].doc
> fred[[1].doc
> fred]


Correct

> ######################################
> fred[1]*: @CandidateOrigFiles:
>


Correct. This would match "fred1" or "fred19" because the unescaped []
pair creates a character class (globbing-style).


> ######################################
> fred\[1\]*: @CandidateOrigFiles:
> fred[1]
> fred[1].doc


Correct

> ######################################
> fred\[1]*: @CandidateOrigFiles:
> fred[1]
> fred[1].doc


I think this is correct, but I'm not sure.

> ######################################
> fred[1\]*: @CandidateOrigFiles:
> fred[1]
> fred[1].doc


What? That doesn't look right to me. The "[" should start a character class.


> ######################################
> fre\ d*: @CandidateOrigFiles:
> fre d[1].doc


Correct

> ######################################
> fre\ d\[*: @CandidateOrigFiles:
> fre d[1].doc


Correct

> ######################################
> fre\ d\[1*: @CandidateOrigFiles:
> fre d[1].doc


Correct

> ######################################
> fre\ d\[1\]*: @CandidateOrigFiles:
>


Hmm, "fre d[1].doc" should appear.

> ######################################
> fre?d\[1\]*: @CandidateOrigFiles:
> fre d[1].doc


Correct

> ######################################
> fre\ d?1\]*: @CandidateOrigFiles:
> fre d[1].doc
>


Correct

> ----
>
> DS


Clearly, an escaped space does not cause the problem. It has something
to do with both an escaped space and an escaped bracket.

--
paduille.4058.mumia.w@earthlink.net
David Squire

2006-09-27, 7:01 pm

Mumia W. (reading news) wrote:

>
> Clearly, an escaped space does not cause the problem. It has something
> to do with both an escaped space and an escaped bracket.


Yes, that's what "too" means in the subject line :) It is the
combination that is the problem.

DS
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com