Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Finding Oldest File in a Directory

by sk (Curate)
on Oct 09, 2005 at 00:48 UTC ( #498479=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Finding Oldest File in a Directory
in thread Finding Oldest File in a Directory

It has been a while since i posted this - I think i looked at the OP's readdir() and somehow felt he is doing some kind of recursion as for just checking the oldest file in a directory can be accomplished using glob or just use the Plain Old Shell and call the script with a * (check for -d etc.) or ls -lrt

That said, I agree File::Find might not be the best way to solve this problem but it can be used to achieve what the OP wants as GrandFather has shown or just eval finddepth and die on finding a directory as finddepth works bottoms-up.

I just find it much easier to use File::Find and it is very easy to expand (if recursion is ever required).

I am not worried too much about performance in this case even if it is 4X times slower. How many times do i have to remove the oldest file? Am i working with 1000s of files? etc. The OP has not mentioned anything about perormance so i am presuming that arg is not very important.

I definitely DO NOT disagree with your comment(s). It is my mistake not noticing that OP did not ask for recursion, I will update my node saying it does recursion and it is upto the OP to choose it or not.

cheers

SK


Comment on Re^3: Finding Oldest File in a Directory
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://498479]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-12-26 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls