You know how troublesome it is when there are two (or more) people in the room with you who have the same name and you want to address only one of them? Well Perl has the same trouble with variables. You have introduced two array variables with the same name in the same room (for room read: lexical scope (set of {})) - kinda like having identical twins dressed and groomed the same with the same name in the room. Perl warns you about that, then just uses one of them completely ignoring the other.

Actually your whole script is still full of bugs. I'll let you go off and read the rest of the replies you got so you can fix some of them yourself. Come back if you don't get it sorted out.

BTW, a good technique that may save you a lot of grief is to comment out you rmtree code and use a print instead as a trial run to see what is going to be deleted when you reinstate the rmtree and run again.

True laziness is hard work

In reply to Re^3: Syntax Error deleting files and folders in a directory by GrandFather
in thread Syntax Error deleting files and folders in a directory by smturner1

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.