#use strict; $comparetime="0"; sub compare; $Clinrxdir="DIRECTORY GOES HERE"; 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"; system("pause"); sub compare($){ local( $string ) = shift; if($comparetime > $string){ $file=$cpupdate;} else{$compare=$m_time;} }