Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Deleting old files from directory

by Anonymous Monk
on Sep 27, 2011 at 19:48 UTC ( #928161=note: print w/replies, xml ) Need Help??


in reply to Deleting old files from directory

Just need to know if this is efficient or if there is a better way of doing this.

It is more efficient to stat only once, ie

grep {-f $_ and 10 < -M _ }
stat, -X

Replies are listed 'Best First'.
Re^2: Deleting old files from directory
by Anonymous Monk on Sep 27, 2011 at 20:03 UTC
    this is what you mean?
    foreach (grep {-f $_ and 10 < -M _ } @files) { print "\n Deleting::: $_\n"; unlink $_; }

      Almost

      Simply replace EXISTING grep block with mine, no need to change anything else

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928161]
help
Chatterbox?
LanX 1 ..2 ..3 ..4 .. is erix missing ;-)
LanX is Discipulus reciting "Springtime for Hitler" ?
[choroba]: erix could tell you how to do it in Postgres
[LanX]: NOOOOOOOOOOOOOOO not again
[chacham]: wow, mysql really is as bad as i thougt
[choroba]: completion?
[LanX]: That's what he usually does when MySQL is mentioned ;-)
[chacham]: the same thing could be achieved with a trigger
[LanX]: choroba yes
chacham shudders at the thought of using a trigger...so evil

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2017-03-30 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (360 votes). Check out past polls.