-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm trying to setup a script to recursively step through a directory and
take action on files and directories. Pretty simple, eh? <br/>
<br/>
My script runs perfectly well and can handle the files and directory
entries differently, it is only when I recursively call the subroutine
that it fails. The script recursively dives into the sub-directory,
but when it is done with that directory the recursive call appears to kill
the whole loop.<br/>
<br/>
Here is my code -- what am I missing?<br/>
<br/>
<pre> 1 #!/bin/perl -w<br/>
2 use strict;<br/>
3 <br/>
4 sub ProcFiles {<br/>
5 my $dir = shift;<br/>
6 <br/>
7 opendir (DIR, $dir) or die $!;<br/>
8 <br/>
9 while (my $file = readdir(DIR)) {<br/>
10 next if ( -d "$dir/$file" &&
$file =~ /^\./);<br/>
11 if (-d "$dir/$file") {<br/>
12 printf ("Diving into
\"%s/%s\".\n", $dir, $file);<br/>
13
&ProcFiles("$dir/$file");<br/>
14 next;<br/>
15 }<br/>
16 <br/>
17 printf ("Adding
\"%s/%s\".\n", $dir, $file);<br/>
18 }<br/>
19 <br/>
20 closedir(DIR);<br/>
21 }<br/>
22 <br/>
23 &ProcFiles ("/tmp");</pre>
Dan<br/>
<br/>
<br/>
- - - - -<br/>
"Wait for that wisest of all counselors, time." -- Pericles<br/>
"I do not fear computer, I fear the lack of them." -- Isaac
Asimov<br/>
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDehwesrDMR0/em2gRAmPOAKCFjcQ3dUGuDjPx1jrr8xPDT57JegCgg/W6
mNoWjzNdW7e1BjjoP0x6VdE=
=kDJ/
-----END PGP SIGNATURE-----