Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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


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

use Modern::Perl; my @files = qw { ./ ./ }; 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 ./ Current time: 1372263479 ./, 1372261299 color is green ./, 1372262161 color is green

I hope this helps


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040815]
[Corion]: marto: Oh ;) Well, I think you did right - more time, even if not spent with the kids directly, is still more time for you.
[Discipulus]: good morning monks! town holiday here.. but super busy
Discipulus time is not comarable with money.. when you have a roof and something to eat
[Corion]: Hi Discipulus! Busy making the town better? ;)

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2017-06-29 08:37 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (655 votes). Check out past polls.