Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 romping around the Monastery: (16)
As of 2014-09-18 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (120 votes), past polls