In addition, this code is weird:
if (defined (@ARGV) $ARGV[0]=~/-all/) { $mode="all"; } else { $mode=""; }
What is that $ARGV[0]=~/-all/ doing out there? Do you want an && or and in there? Also:
if (-d $file) { &scandir;
You're not chdiring into $file first, nor are you passing that to &scandir, so it looks to me like it's just going to repeat itself in the current directory/context again.

You're also calling &scandir twice in your code.. once towards the top and once at the bottom (for "."). Not sure if you intended to do that or not.

It looks to me like you need to figure out how you're wanting your functions to be called, and perhaps re-work the way you're passing arguments around.

Take a look at File::Find and File::Recurse also.


In reply to Re: Yet another problem with recursive code by Fastolfe
in thread Yet another problem with recursive code by curtisb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.