Well, in the bash shell I'd say something like:

find . -mtime -59 -type d -print | xargs rm -rf
(the argument may not be exactly right, do a man on find for the right args, and I'd also do whatever option xargs has to *not* execute if nothing comes down the pipe, but then this is a perl question, so ...)

Well, so in perl I'd do something dumb like run the 'find' command above (without the rm), fiddle with the output in any way I felt reasonable, then either use a perl-based 'rm -rf' or run another shell command.

Not very perl-ish, I'm afraid, and probably pushing the 'more than one way to do it' a bit too far, but if you wanted to perl-ize it more do a cpan lookup for a 'find' replacement (which I'm sure you could write or find - I mean, its just 'open directory', get its age, and recurse), and for a 'rm -rf' replacment).

Oh, goodness: there is a 'find' at http://search.cpan.org/perldoc?File::Find but it doesn't check the status. Perhaps you should check out 'find2perl', to which you give my above script (or something similar), and it will spit out the perl... see http://search.cpan.org/~nwclark/perl-5.8.8/x2p/find2perl.PL


In reply to Re: rm old directory by Anonymous Monk
in thread rm old directory by Anonymous Monk

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.