Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Like, I *love* Date::Manip, that's just me I lllllike it. But if you don't have holidays inputted correctly (especially if you aren't in the U.S.) or hey they added another holiday, well you only have 9 files.

So why not just keep 13 or 14 files? Is each one so huge that you are going to wreck your partition? Laziness is a virtue in Perl and saves you time too. I'm going to stick to that and not post any code! :)

Also, I would say don't worry so much about dates. You have a process that is generating a file a day, *if* it's running. Count how many files you have in the directory once a day and unlink the last one. You might even be able to parse the file names to be sure, because what if someone touches one, or you do a recovery from backup. If these are important files look at what is the easiest way to ensure your integrity.

The easiest way I can think of doing that if you are in control of file naming is to name files in sequential order, sort the file names, and determine the next file number. Perhaps you could even use time(). Otherwise if you are really sure you want to get rid of the oldest file, -M or stat will do the age checking part (in unix anyway, don't quote me for Windows).


In reply to Re: find "x" quantity newest files in a dir by mattr
in thread find "x" quantity newest files in a dir by braintoast

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found