All,

My goal is to get element 9 of stat which is mtime.  I am getting this with
ease, but my end goal is to convert this number back into a readable format
giving me how old the file is.

So here is a rough draft formula :  (time in seconds  -  last  MTime ) =
seconds old.

Convert seconds old to a human readable time stamp using localtime ();
Any ideas or is there a better way?

thank you,




Here is my code:



#!/usr/bin/perl
use strict;
use warnings;
$ENV{"PATH"} = qq(/opt/SUNWsamfs/sbin:/usr/bin:/usr/sbin:/usr/local/log);

#my $fdirs =
qq(/fuji/original/RMH/*,/fuji/original/GMC/*,/fuji/clinical/GMC/*,/fuji/clinical/RMH/*);
#my $fdirs = qq(/fuji/original/RMH/0*);


my $hdir   = qq(/heartlab/db studies/);
$^T=time;
our $now   = time();


#sub dateme
#         {
#                  my ($hour,$min,$month,$day,$year) =
(localtime)[2,1,4,3,5];
#                  sprintf ("%02d:%02d   %02d/%02d/%02d\n",
$hour,$min,$month+1,$day,($year % 100));
#        }
#
#                  my $dm = &dateme;

opendir (DH, $hdir) or die "unable to open directory: $hdir $!";

          foreach my $file (sort readdir (DH))
          {
                   next if $file eq "." or $file eq "..";
                   print "All file timestamps in $hdir
are:\t",$file,":\t",(stat("${hdir}${file}"))[9],"\n";
                   #print "Last modified time timestamps in $hdir
are:\t",$file,":\t", ($now - (stat("${hdir}${file}"))[9])*60,"\n";
          }

closedir (DH) or warn "unable to close DH: $hdir $!;




Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to