Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: list files based on age and pattern

by RichardK (Parson)
on Sep 16, 2013 at 11:54 UTC ( #1054281=note: print w/replies, xml ) Need Help??


in reply to list files based on age and pattern

I prefer to use File::Find::Rule for this kind of thing, it's easy to use and very flexible.

So your query could look like this :-

my @files = File::Find::Rule->file->name('_NSA*.xml')->mtime('<' . (t +ime() - 60 * 15) )->in($path);

Replies are listed 'Best First'.
Re^2: list files based on age and pattern
by kaka_2 (Sexton) on Sep 16, 2013 at 13:23 UTC

    Hello Richard,

    I tried as you suggested but it gives me error "cant locate object method "file" via package file::find::rule..........

    my perl version is v5.8.8 and upgrade is not an option on client machine.

    -KAKA-

      You would need to add a line

      use File::Find::Rule;

      somewhere at the top of your script. (Assuming this module is installed on your machine.) Also, have a look at the examples in the documentation as linked in CountZero's post.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054281]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2016-12-03 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (55 votes). Check out past polls.