-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

<br/>
On Tue, November 15, 2005 13:31, Theodore Katseres wrote:<br/>
&gt; It appears that no recursion is happening passed the initial dive.
{<br/>
&gt; ProcFiles(&quot;/tmp&quot;) }<br/>
<br/>
I agree -- when I take out the '<span
class="Code">&amp;ProcFiles(&quot;$dir/$file&quot;);</span>' line, it
continues through the /tmp directory fine.&nbsp; With the recursive call
to itself, I can watch the script dive into the sub-directory (/tmp/dir1),
and it processes all the files in /tmp/dir1, but when it finishes with the
files in &quot;dir1&quot; the program quits.&nbsp; Unless I am missing
something, I thought it should go back one level to the initial invocation
of ProcFiles and continue where it left off there...<br/>
<br/>
&gt; Check my comments.<br/>
&gt; <br/>
&gt; &lt;Snip &amp;&amp; Replace&gt;<br/>
&gt; #!/bin/perl -w<br/>
&gt; use strict;<br/>
&gt; <br/>
&gt; sub ProcFiles {<br/>
&gt;     my $dir = shift;<br/>
&gt; <br/>
&gt;     opendir( DIR, $dir ) or die $!;<br/>
&gt; <br/>
&gt;     while ( my $file = readdir(DIR) ) {<br/>
&gt; <br/>
&gt;         next if ( -d &quot;$dir/$file&quot; &amp;&amp; $file =~ /^\./
);<br/>
&gt; <br/>
&gt;         # above makes sure this block of code never gets executed<br/>
<br/>
The line you mention (&quot;next if ...&quot;) is used to make sure I skip
the &quot;.&quot; and &quot;..&quot; entries in the subdirectory --
otherwise it would back out of the &quot;/tmp&quot; to &quot;/&quot; and
work there! :(&nbsp; (It also has the effect of ignoring files with a
leading &quot;.&quot; -- that's also by design.)<br/>
<br/>
&gt;         if ( -d &quot;$dir/$file&quot; ) {<br/>
&gt; <br/>
&gt;             printf( &quot;Diving into\&quot;%s/%s\&quot;.\n&quot;,
$dir, $file );<br/>
&gt; <br/>
&gt;             &amp;ProcFiles(&quot;$dir/$file&quot;);<br/>
&gt; <br/>
&gt;             next;<br/>
&gt; <br/>
&gt;         }<br/>
&gt; <br/>
&gt;         # your printing files that don't begin with &quot;.&quot;<br/>
<br/>
True -- in my real script, this print line is replaced with a small bit of
code to do some real work! In the example I posted to OLUG I wanted to
keep it simple and see if I could make it work...<br/>
<br/>
&gt;         printf( &quot;Adding\&quot;%s/%s\&quot;.\n&quot;, $dir, $file
);<br/>
&gt; <br/>
&gt;     }<br/>
&gt; <br/>
&gt;     closedir(DIR);<br/>
&gt; <br/>
&gt; }<br/>
&gt; <br/>
&gt; &amp;ProcFiles(&quot;/tmp&quot;);<br/>
<br/>
Ted, thanks for your input.<br/>
<br/>
Dan<br/>
<br/>
- - - - -<br/>
&quot;Wait for that wisest of all counselors, time.&quot; -- Pericles<br/>
&quot;I do not fear computer, I fear the lack of them.&quot; -- 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)

iD8DBQFDejqusrDMR0/em2gRAtT2AJ9cL6zR+u/XpmGtjXNCCM/Y9WDcvwCfY1Fp
qXscyNVDA6vb5H8MuKUrEtM=
=mFaZ
-----END PGP SIGNATURE-----