Unexpected glob behavior nt4-ActivePerl-5.6 
Author Message
 Unexpected glob behavior nt4-ActivePerl-5.6

mkdir ("c:\\Jan Slater");           # Create a directory with a space in
the name.

open (Out,">c:\\Jan Slater\\dah");  # Put something in the directory
print Out "DAH\n";
close(Out);

$It = "c:\\Jan Slater\\*";          # Build a thing to help search for
files in that directory

directory


{
    print "The file is <$File>\n";  # Show me the name

Quote:
};

# Resulting output looks like this
# The file is <c:./Jan>

# I am expecting
# The file is <C:\Jan Slater\dah>

# My Configuration looks something like this

# Winnt 40 service pack 4

#C:\>perl -v

#This is perl, v5.6.0 built for MSWin32-x86-multi-thread
#(with 1 registered patch, see perl -V for more detail)

#Copyright 1987-2000, Larry Wall

#Binary build 613 provided by ActiveState Tool Corp.
http://www.*-*-*.com/
#Built 12:36:25 Mar 24 2000

# Is this a bug?  A feature?  An unreasonable expectation on my part?
# Can someone point me to some docs that describe the correct behavior
# or suggest a workaround?

# Thanks

#   jan



Mon, 21 Oct 2002 03:00:00 GMT  
 Unexpected glob behavior nt4-ActivePerl-5.6


Quote:

> $It = "c:\\Jan Slater\\*";          # Build a thing to help search
for

the


> {
>     print "The file is <$File>\n";  # Show me the name
> };

> # Resulting output looks like this
> # The file is <c:./Jan>

> # My Configuration looks something like this

> # Winnt 40 service pack 4

> #C:\>perl -v

> #This is perl, v5.6.0 built for MSWin32-x86-multi-thread
> #(with 1 registered patch, see perl -V for more detail)

> #Copyright 1987-2000, Larry Wall

> #Binary build 613 provided by ActiveState Tool Corp.
> http://www.ActiveState.com
> #Built 12:36:25 Mar 24 2000

Definitely something to do with the windows port.

On my copy of Activestate (v5.005_03, build 517) running on Win98 I
get zero results from the glob. I thought initially it was an issue
with quoting the spaces (as tho at a DOS prompt), like

    $It = "\"c:\\Jan Slater\\*\"";

but that did nothing for me either.

Whereas on my linux box, everything works fine with spaces.

Would suggest checking the ActiveState docs and see it someone else
has come across this.

--
  Richard Huxton
  Archonet Ltd.



Mon, 21 Oct 2002 03:00:00 GMT  
 Unexpected glob behavior nt4-ActivePerl-5.6

Quote:

> Definitely something to do with the windows port.

I'm not so sure as you seem to be.

Quote:
> Whereas on my linux box, everything works fine with spaces.

Really? Not on mine. Could you post some test code which demonstrates this
on Linux (or any Unix flavor) under Perl 5.6? (I specify 5.6 because
globbing is different in earlier versions.)

A glob of something looking like "Jan Slater/*" traditionally means the
same as a glob of "Jan" followed by a glob of "Slater/*". (That is, "Jan",
whether there's a file by that name or not, followed by anything matching
the second glob pattern.) In short, spaces normally separate glob
elements.

But maybe I'm missing something here. Wouldn't be the first time! :-)

--
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



Tue, 22 Oct 2002 03:00:00 GMT  
 Unexpected glob behavior nt4-ActivePerl-5.6

Quote:


> > Definitely something to do with the windows port.

> I'm not so sure as you seem to be.

> > Whereas on my linux box, everything works fine with spaces.

> Really? Not on mine. Could you post some test code which demonstrates this
> on Linux (or any Unix flavor) under Perl 5.6? (I specify 5.6 because
> globbing is different in earlier versions.)

It doesn't work on Solaris2.7, perl.5.6.0...

The script...
mkdir("./Jan Slater");
open (FOO,">./Jan Slater/foo");
print FOO "foo\n";
close(FOO);

mkdir("./Slater");
open (BAR,">./Slater/bar");
print BAR "bar\n";
close(BAR);


        print "The file is <$File>\n";

Quote:
};

Produced the following output...
The file is <./Jan>
The file is <Slater/bar>  

/Peter



Wed, 23 Oct 2002 03:00:00 GMT  
 Unexpected glob behavior nt4-ActivePerl-5.6
)
) A glob of something looking like "Jan Slater/*" traditionally means the
) same as a glob of "Jan" followed by a glob of "Slater/*". (That is, "Jan",
) whether there's a file by that name or not, followed by anything matching
) the second glob pattern.) In short, spaces normally separate glob
) elements.
)
) But maybe I'm missing something here. Wouldn't be the first time! :-)

That tradition was as much an accident of the previous
implementation that used /bin/csh.  If you want

    <Jan>, <Slater/*>

then you should write that and _not_

    <Jan Slater/*>

but we certainly need to support backward compatability on this
point.

Since Perl is very much _not_ the type of environment that imposes
arbitrary restrictions such as being unable to deal with file
names that contain strange characters [and space is not nearly as
strange as other characters that Perl easily handles in file name
globs], Perl's glob() should certainly allow spaces in file name
globs.

You can currently [that is, in Perl5.6] work around the problem
via:

    <Jan?Slater/*>

[as long as you don't also have a "Jan-Slater" directory, for
example].  You used to be able to _also_ work around the problem
[without the above restriction] via:

    <Jan\\ Slater/*>
or
    <Jan" "Slater/*>

Sorry, I don't have a running Perl5.6 install handy to test
whether either of these continue to work with the new glob()
[though it looks like Text::ParseWords is used so they probably
do].

To quote File/Glob.pm:

    # XXX this is needed for compatibility with the csh
    # implementation in Perl.  Need to support a flag
    # to disable this behavior.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)



Sat, 26 Oct 2002 03:00:00 GMT  
 Unexpected glob behavior nt4-ActivePerl-5.6

Quote:
> Since Perl is very much _not_ the type of environment that imposes
> arbitrary restrictions such as being unable to deal with file names
> that contain strange characters [and space is not nearly as strange as
> other characters that Perl easily handles in file name globs], Perl's
> glob() should certainly allow spaces in file name globs.

Just to clarify, I think you mean "upon request". That is, this would not
be the default behavior, so as to not break existing code which does
things like this:


    my $dir = "/home/oscar";

Cheers!

--
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



Sat, 26 Oct 2002 03:00:00 GMT  
 Unexpected glob behavior nt4-ActivePerl-5.6

) > Since Perl is very much _not_ the type of environment that imposes
) > arbitrary restrictions such as being unable to deal with file names
) > that contain strange characters [and space is not nearly as strange as
) > other characters that Perl easily handles in file name globs], Perl's
) > glob() should certainly allow spaces in file name globs.

) Just to clarify, I think you mean "upon request". That is, this would not
) be the default behavior, so as to not break existing code

Actually, I'd prefer that the default upon finding a space in a
file name glob would be "break on spaces but warn if warnings are
on".  And then there would be two options, something like

    use File::Glob qw/ :matchspaces /;  # Spaces are part of the glob

    use File::Glob qw/ :splitspaces /;  # Split on spaces

both of which would disable this warning.  [Note that I didn't
go the C<:spaces>/C<:nospaces> route like the existing
C<:case>/C<:nocase> options which usually make me wonder whether
they mean "[no] case matching" or "[no] case ignoring".]

But then I don't have the luxury of working only on platforms
where spaces in file names are strongly discouraged [nor only on
platforms where spaces in file names are well supported -- thank
you Microsoft  );  for making systems that do neither].

Sorry, I don't have time to provide a patch.  Though I'll put it
in my to-do list.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)



Sat, 26 Oct 2002 03:00:00 GMT  
 Unexpected glob behavior nt4-ActivePerl-5.6

Quote:
>>From Jan Dubois at ActiveState...

It's a "backwards compatibility" feature. :-)  In Perl, glob("a* b*") used
to
mean "all files starting with either 'a' or 'b'".

I think you can get the effect you want by including the following statement
at

the top of your program:

    use File::Glob ':glob';
--------------------------------------------------------------------
My thanks to everyone that responded.

Jan



Sun, 27 Oct 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. How do you create database tables?

2. Use Delphi to Access via DAO 2516.dll

3. Local SQL changed in D2?!

4. I will help another Delphi 1.0 programmer.

5. Borland Database Engine

6. FLC Viewer

7. redirect sound to sb16 speakers?

8. Searching Key Field in Child Table

9. Unexpected sort behavior with perl5b1

10. unexpected behavior

11. list/stat unexpected behavior

12. unexpected tr-behavior?

 

 
Powered by phpBB® Forum Software