[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Recursively visit all files in a directo



on 12/27/2000 06:40 PM, Jim Correia at correia@barebones.com wrote:

> my $dir         = shift(@_);
> my $callback    = shift(@_);
> my $path_delim  = ( $OSNAME eq 'MacOS' ? ':' : '/' );
> my $f;
> my @listing;
> 
> $dir =~ s/$path_delim$//; # strip of the trailing path delimiter
> 
> opendir(DIR, $dir) || croak "can't opendir $dir";
> @listing = readdir(DIR);
> closedir(DIR);
> 
> while ( defined($f = shift(@listing) ) )
> {


File::Spec

my $dir = File::Spec->catfile( File::Spec->curdir(), 'mysubdir', '');

etc etc

worth looking into if you do cross platform work often.



-- 
Scott R. Godin            | e-mail : mactech@webdragon.net
Laughing Dragon Services  |    web : http://www.webdragon.net/



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org