Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Deleting old files from directory

by Lotus1 (Chaplain)
on Sep 27, 2011 at 20:41 UTC ( #928182=note: print w/ replies, xml ) Need Help??


in reply to Deleting old files from directory

Here is how to do it without the array and without using grep.

I prefer File::Glob these days since it allows whitespace in the path but it won't work like this in a while loop so I end up with a foreach loop and an array.

#!/usr/bin/perl use warnings; use strict; while (<test/*.txt>) { if (-f && 10 < -M _) { print "\n Deleting::: $_\n"; unlink or warn "--Could not unlink $_: $!"; } }


Comment on Re: Deleting old files from directory
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2014-09-22 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (197 votes), past polls