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;} }
In reply to Re: Compare script
by TheRedcoat
in thread Compare script
by TheRedcoat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |