Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Test files not being processed

by bofh_of_oz (Hermit)
on Jul 20, 2005 at 15:32 UTC ( #476532=note: print w/replies, xml ) Need Help??

in reply to Test files not being processed

Firstly, do you have a timestamp in the name of those files? If so, you can use glob and regex the filenames...

If not, you can use this:

use strict; use warnings; use File::Glob; my $path = ""; my ($oldest, $fname) = (time, ''); my $modtime; chdir $path; foreach (glob("*")) { if (-f) { $modtime = (stat($_))[10]; ($oldest = $modtime and $fname = $_) if ($oldest > $modtime); } } print "$fname\t$oldest\n"; (abs(time() - $oldest) < 300) ? print "File recent enough\n" : print "Reporting an error\n";
This will go through files in a directory ($path), find the oldest file, check if it was modified (created or overwritten) within last 300 seconds... the rest insert accordingly.

An idea is not responsible for the people who believe in it...

Replies are listed 'Best First'.
Re^2: Test files not being processed
by BadHabit (Initiate) on Jul 20, 2005 at 16:28 UTC
    Hurrah for bofh_of_oz! I had been re-working the script to regex the timestamp but I think your code is much more succinct and reusable.

    I not only now love PERL (only been playing for three weeks), I also love this forum.

    Thanks to ARUNBEAR for the READMORE tags, I shall use them in future.
Re^2: Test files not being processed
by Anonymous Monk on Sep 28, 2005 at 17:37 UTC
    I think the above will help me to see if new files are being written to my server, but I do not understand how $oldest is the oldest file.
    I need to know that the newest file was modified in the last ten minutes, so could someone explain the logic so I can hack this code myself?
    Thanks Monks . . .

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://476532]
[erix]: swedes in winter have too much time on their hands

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2018-02-22 15:33 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (294 votes). Check out past polls.