in reply to file with a blank in its name

While I agree with everyone that suggests readdir over glob for anything but a quick hack, is this a platform-dependent problem (ie, a shell thing)? Both 5.6 and 5.005_03's glob work fine for me on Linux:
chh@scallop ~> touch "Foo bar" chh@scallop ~> perl -le 'print grep /\s/, <*>' Foo bar chh@scallop ~> perl -le '@f = <*>; print grep /\s/, @f' Foo bar
I'm on the road and don't have access to a Windows box to check, but I seem to remember something funky about Win32's glob and long filenames.

Replies are listed 'Best First'.
RE: Re: file with a blank in its name
by chromatic (Archbishop) on May 06, 2000 at 01:06 UTC
    It works for me with both ActiveState 522 and 613 (that's 5.005_3 and 5.6, for those of you keeping score) on NT. My test program was:
    my @files = grep /\s/, <*>; foreach my $file (@files) { print ">>$file<<\n"; }
    On both versions, that caught long filenames successfully. On a Linux box with GNU bash, version 1.14.7(1) and Perl 5.005_3, it works as well.

    (since the Win98 box has become a Linux Distribution Installer Testbed, I can't report on that. :)

RE: Re: file with a blank in its name
by BBQ (Curate) on May 06, 2000 at 22:56 UTC
    I had heard in the past that ActiveState's distribution had a quirky glob, it that it would only return the correct values for "*.*" instead of "*", but I have just run a test on a NT box and this is what I got...
    Orders, Sir? cd \usr\local Orders, Sir? ls -la total 0 -d---- 0 3-Mar-100 03:28 . -d---- 0 3-Mar-100 03:28 .. -d---- 0 3-Mar-100 03:29 apache -d---- 0 15-Apr-100 21:37 bin -d---- 0 7-Dec-99 03:34 cgi-bin -d---- 0 6-Dec-99 21:58 ftpd ad---- 0 24-Feb-100 18:24 httpd -d---- 0 7-Dec-99 02:19 iissamples -d---- 0 22-Apr-100 22:45 mysql -d---- 0 6-Dec-99 21:58 scripts -d---- 0 7-Dec-99 21:11 uia Orders, Sir? perl foreach (glob("*")) { print ++$x.". $_\n"; } ^Z 1. apache 2. bin 3. cgi-bin 4. ftpd 5. httpd 6. iissamples 7. mysql 8. scripts 9. uia Orders, Sir?
    Apart from the current directory and the parent directory, everything got listed, exactly as it would on a real system. (and I know the contents of \usr\local don't look too much like an NT box, but beleive me! It is! I just don't like the stuff that ships with NT)
RE: Re: file with a blank in its name
by takshaka (Friar) on May 08, 2000 at 06:48 UTC
    Well, to close the book on the tests, I checked ActiveState 522 on Win98SE and got the same results as on NT. <*> returns long filenames--with or without extensions, with or without spaces--and does not do an implicit split on the list when assigning to an array. I can't reproduce the behavior cited by the OP.

    However, in spite of all evidence to the contrary, I still believe there are some issues with 522's glob.