Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Comparing file properties

by arnaud99 (Beadle)
on Jun 26, 2013 at 16:19 UTC ( #1040815=note: print w/ replies, xml ) Need Help??


in reply to Comparing file properties

Hi

Not using File::Stat, and using the 'core' stat, may be one solution

use Modern::Perl; my @files = qw { ./adt1.pl ./adt2.pl }; my $color; my $cur_time = time; my @quake_times = qw( 21600 3600); say 'Current time: ', $cur_time; foreach my $a_filename(@files) { #stat() on the file name my $mtime = (stat($a_filename))[9]; say $a_filename, ", " , $mtime; if (($cur_time - $mtime) > $quake_times[1]) { $color = 'red'; } elsif (($cur_time - $mtime) > $quake_times[0]) { $color = 'yellow'; } else { $color = 'green'; } say ("color is ", $color, "\n"); }

The code above outputs:

~/perl/ex/perlmonks: perl ./adt5.pl Current time: 1372263479 ./adt1.pl, 1372261299 color is green ./adt2.pl, 1372262161 color is green

I hope this helps

Arnaud


Comment on Re: Comparing file properties
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2015-07-28 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls