#!/opt/local/bin/perl use strict; use warnings; use File::stat; # initialize my $element; my $filename; my $fh; my @files; my $sb; my @quake_times; my $color; my $cur_time = time; my $mtime; print ("current time is ", $cur_time, "\n" ); @quake_times = qw( 21600 3600); @files = qw( markers/quake markers/volcano satellites/NORAD.tle); my $directory = "/Users/coblem/xplanet/"; foreach $element (@files) { $filename = $directory . $element; open $fh, '<', $filename; #$sb = stat($fh); # scalar localtime $sb->mtime; $mtime = (stat($fh))[9]; print ($cur_time , " ", $mtime); if (($cur_time - $mtime) > @quake_times[1]) { $color = 'red'; } elsif (($cur_time - $mtime) > @quake_times[0]) { $color = 'yellow'; } else { $color = 'green'; } print ("color is ", $color, "\n"); } #### Last login: Tue Jun 25 21:03:59 on ttys000 usxxcoblemm1:~ coblem$ cd testing usxxcoblemm1:testing coblem$ ls Global_24h.csv csv_loading.pl hello_world Quakes filestats.pl hello_world.pl change_blue_marble.pl filestats_2.pl volcano_script.sh clouds_4096.sh fire.csv usxxcoblemm1:testing coblem$ perl filestat2_2.pl Can't open perl script "filestat2_2.pl": No such file or directory usxxcoblemm1:testing coblem$ perl filestats_2.pl Scalar value @quake_times[1] better written as $quake_times[1] at filestats_2.pl line 36. Scalar value @quake_times[0] better written as $quake_times[0] at filestats_2.pl line 39. current time is 1372261642 Use of uninitialized value $mtime in print at filestats_2.pl line 34. Use of uninitialized value $mtime in subtraction (-) at filestats_2.pl line 36. 1372261642 color is red Use of uninitialized value $mtime in print at filestats_2.pl line 34. Use of uninitialized value $mtime in subtraction (-) at filestats_2.pl line 36. 1372261642 color is red Use of uninitialized value $mtime in print at filestats_2.pl line 34. Use of uninitialized value $mtime in subtraction (-) at filestats_2.pl line 36. 1372261642 color is red usxxcoblemm1:testing coblem$ #### Scalar value @quake_times[1] better written as $quake_times[1] at filestats_2.pl line 36. Scalar value @quake_times[0] better written as $quake_times[0] at filestats_2.pl line 39. current time is 1372261739 1372261739 File::stat=ARRAY(0x7f8fc902d7b0)color is green 1372261739 File::stat=ARRAY(0x7f8fc9055238)color is green 1372261739 File::stat=ARRAY(0x7f8fc9055190)color is green usxxcoblemm1:testing coblem$