perl
Ben Coffman
ben_coffman at hotmail.com
Tue Mar 2 21:25:41 CST 2004
When designing a <perl> script to go through a directory tree I ran into a
problem. The script crawls through the tree fine ONLY IF when I read all
the contents of a folder into an array with the readdir command the folders
are listed before the files. If by chance a file is tested to see if it is
a directory then the next element it reads from the array is a directory,
for some reason it can't recognize that as a directory...or a file for that
matter. Below is an example of what the output is. The directory it is in
is 'e.'
"hi" is a file name
"no" is a file name
"abc" is a directory
What it should do is check and see that hi is not a directory and skip it
same with no, then with abc it should jump in and read the contents of that
folder. But as you can see after it reads hi it cannot reconize anything
else. Any suggestons would be great!
Array name 0 is : .
Array name 1 is : ..
Array name 2 is : hi
Array name 3 is : no
Array name 4 is : abc
Array name 5 is :
the name is: hi
file output: hi: empty file
workdir2: e
startdir2: /home/coffmanb/stuff/a/b
the name is: no
file output: no: cannot open: No such file or directory
workdir2: e
startdir2: /home/coffmanb/stuff/a/b
the name is: abc
file output: abc: cannot open: No such file or directory
workdir2: e
_________________________________________________________________
One-click access to Hotmail from any Web page download MSN Toolbar now!
http://clk.atdmt.com/AVE/go/onm00200413ave/direct/01/
More information about the Kclug
mailing list