Why don't you just concatenate "$hifolder/$lowfolder"? That is unique and gives you the absolute path that you would wind up using to delete the directory anyway. You probably need to prepend $hipath to the $highfolder name perhaps in the loop that iterates over the $highfolders".

my @FullDirPaths = map{"$hipath/$highfolder/$_"}@LowFolders;

You might want to look at Date::Time module for comparing dates. Or you could make a little YYYYMM "date math" routine yourself, but I suspect that using the module will be easier.

Don't know if this is a typo or not, but don't put a ";" after the "->" ie have "->new();"

Update: Don't know where my brain is this morning...Actually I don't think that you need to save the @FullDirPaths like above at all. At this point in the code you have all 3 parts of the full path: "$hipath/$highfolder/$lowfolder". Just decide right there whether or not you should delete this particular $lowfolder or not! No need to save the names to process later. You can use a simple regex to separate out the month and year from the filename like shown below...

my @dates = ( '1010', '1007'); foreach my $date (@dates) { my ($year,$mon) = $date =~ m/\d\d/g; print "year = $year month= $mon\n"; }

In reply to Re: Deleting folders based on name. by Marshall
in thread Deleting folders based on name. by fazedandconfused

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.