in reply to Re: Determine if object is file or directory?
in thread Determine if object is file or directory?

Remember to prepend the directory to the filename:
opendir D, "pbed" or die; while (my $file = readdir D) { if (-d "pbed/$file") { print "dir: $file\n"; } else { print "file: $file\n"; } }

Replies are listed 'Best First'.
Re: Re: Re: Determine if object is file or directory?
by halley (Prior) on Apr 08, 2004 at 12:05 UTC
    Or skip the ugly readdir() dance altogether. It's amazing how many people like going around their elbow to get to their thumb. Use glob() or the angle brackets, that's why they are there.
    @files = grep { not -d } <$path/*>;

    --
    [ e d @ h a l l e y . c c ]