Re: Problems using glob()

2002-08-19 Thread Felix Geerinckx

on Mon, 19 Aug 2002 10:09:16 GMT, [EMAIL PROTECTED] (Jochen Berger)
wrote: 

> I've got a problem with a Perl Script I wrote to find files
> matching a special pattern. It worked fine until I commented it.
> From that time on the program has got problems with that WIN32
> feature called "You want spaces in your file name? Then do it!".
> If the program finds a directory containing a space, it returns
> the path without spaces and backslashes. This doesn't make sense
> to me (especially because it worked before). 

The following code works for me (note the forward slash):

#! perl -w
use strict;

my $dir= 'c:/My Documents/';
my $filter = '*.doc';
my $path   = qq{"$dir$filter"};
my @files  = glob($path);

> BTW: This program was supposed to work either under Unix AND
> Windows. Is there a chance to get the path separator for the
> current operating system like in Java (File.pathSeparator)? 

See

perldoc File::Spec

for portable operations on filenames.

-- 
felix

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Problems using glob()

2002-08-19 Thread Jochen Berger

Hi, y'all!

I've got a problem with a Perl Script I wrote to find files matching a special 
pattern. It worked fine until I commented it. From that time on the program has got 
problems with that WIN32 feature called "You want spaces in your file name? Then do 
it!". If the program finds a directory containing a space, it returns the path without 
spaces and backslashes. This doesn't make sense to me (especially because it worked 
before). Following is the snipplet from the source that causes the troubles:

sub searchFiles {
  # get the arguments
  (my $currDir) = @_;
  # get all files in the directory matching the file filter
  my @allFiles = glob("$currDir\\$filter");

The glob function (I found that one out with debugging) causes the problems. The $file 
variable contains the complete path to check next, and $filter contains the file 
filter (e.g. "*.java").

BTW: This program was supposed to work either under Unix AND Windows. Is there a 
chance to get the path separator for the current operating system like in Java 
(File.pathSeparator)?

Thanks in advance

Jochen Berger

-
Der Verstand und die Fähigkeit, ihn zu gebrauchen, sind zwei verschiedene Gaben.
Franz Grillparzer (österr. Dichter, 1791 - 1872) 

__
Keine Chance fur Viren! Mit WEB.DE FreeMail sind Sie auf der
sicheren Seite - Virenschutz inklusive! http://freemail.web.de/?mc=021129


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]