in reply to file with a blank in its name

I would use opendir and readdir:
opendir (DIR, $dir) or die "cannot opendir $dir"; my @files = readdir(DIR); closedir (DIR);

if you want only files (no subdirectory) you may use:
opendir (DIR, $dir) or die "cannot opendir $dir"; my @only_files = grep {-f "$dir/$_"} readdir(DIR); closedir (DIR);

marcos

Replies are listed 'Best First'.
RE: Re: file with a blank in its name
by infoninja (Friar) on May 05, 2000 at 20:46 UTC
    If you're retrieving all filenames using opendir and readdir (which is the way I usually do it), then you'll want to filter out at least directories (and possibly smylinks as well)
    Here's one way to do it (modified from example in The Perl Cookbook):
    $dir = 'path/to/directory'; opendir(DIR, $dir) or dir "Can't open $dir: $!"; while (defined($file = readdir DIR)) { #Test if $file is a directory unless (-d "$dir/$file") { #Test if $file is a symlink unless (-l "$dir/$file") { #push $file onto @list push(@list,$file); } } }