in reply to Traversing through a directory structure

Couple of things.

First, I would keep the output file open during the whole find operation, by wrapping it around the finddepth:

open FH, ">$WriteDirectory/$file" || die "Can't open $file: $!"; finddepth(&perms, $TraverseDirectory); close FH;

Second, you don't need to backtick-execute pwd. The dir is in $File::Find::dir
see: perldoc File::Find

Just curious, are you doing depth-first for a specific reason?

There are several files and directories under the directory that I'm searching and there has to be an easier way than by going through each directory by hand.

If you really need to visit all the files like this to gather perms info, I don't think there really is an easier way than File::Find

Update: Trying this out on my system, I see it gives the "strict refs" complaint. It needs to be:

finddepth(\&perms, $TraverseDirectory);

Replies are listed 'Best First'.
Re^2: Traversing through a directory structure
by Fletch (Bishop) on Mar 03, 2005 at 01:52 UTC
    open FH, ">$WriteDirectory/$file" || die "Can't open $file: $!";

    You either mean open( FH, ">..." ) || die "..." or open FH, ">..." or die "...". Your code will never execute the die statement because of the precedence problem.

    freebie:~ 601> perl -MO=Deparse,-p open FH, ">$WriteDirectory/$file" || die "Can't open $file: $!"; open(FH, (">$WriteDirectory/$file" || die("Can't open $file: $!")));