Operating System - Tru64 Unix
1748256 Members
3807 Online
108760 Solutions
New Discussion

Returning file modified time as Blank -- why??

 
Puneet Bhatia_1
Occasional Contributor

Returning file modified time as Blank -- why??

Hi
I am trying to find the difference of system time and file last modified time(current_mtime -> calculated through stat command) for the searched files . But it is returning mtime as Blank(null value)for each searched files. Please help me, where i am making the mistake in this script


#!/usr/bin/perl
my $dir_path;
my $cmd;
my $buf;
use strict;
use File::Find;
use File::stat;
my $current_mtime;

$dir_path="/home";
$cmd="ll $dir_path > result";
`$cmd`;

open(MYINPUTFILE, "
while($buf=)
{
my @temp;
push @temp , split(/\s+/,$buf);
if ( $temp[8] =~ m/^mdc/i )
{
# Printing filename , Time and Date
print "\nFile $temp[8] last modified on $temp[7] $temp[6]\n";

find(\&syswanted, '$temp[8]');


# $now is current system unix time
my $now;
$now=`date '+%s'`;
print "\n Now : $now \n";
my $t;

#print "MTime: $current_mtime\n";
$t=($now-$current_mtime)/60;

print " Diff in minutes is: $t \n\n";

}
}


sub syswanted
{

my $file = $_;
print "File: $file\n";

$current_mtime = (stat($file))[8];
print "MTime: $current_mtime\n";

}