in reply to Compare script
I noticed some error's i made with my variable names, I corrected these, it now outputs the oldest timestamp, but does not update the name of the file to go with it.. for instance my timetamp was for file 4 but it was still listing file 1 as the output#use strict; $comparetime="0"; sub compare; $Clinrxdir="D:\\StoreAccess\\shared\\sup shared\\"; opendir(DIR,$Clinrxdir); @Files= readdir(DIR); closedir(DIR); foreach $cpupdate (@Files){ if($cpupdate =~ m/\s*cp_/i){ my $m_time = (stat($Clinrxdir.$cpupdate))[9]; my ($i_wday, $i_month, $day, $year) = (localtime($m_time))[6,4,3,5]; compare($m_time); print "Timestamp for " . $cpupdate . " " . $m_time ."\n"; } } print "This is a test of file = " . $file . "\n"; print $file; system("pause"); sub compare($){ local( $string ) = shift; if($comparetime > $string){ $file=$cpupdate;} else{$comparetime=$string;} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Compare script
by stevieb (Canon) on Aug 29, 2009 at 18:43 UTC | |
|
Re^2: Compare script
by graff (Chancellor) on Aug 30, 2009 at 05:13 UTC |