# Looks in $dir and sets $latest->{file} with newest file and sets $oldest->{file} with oldest file. my ( $latest, $oldest ) = ( sort { $a->{ mtime } <=> $b->{ mtime } } map { { mtime => -M $_, file => $_ } } <$dir/*> )[ 0, -1 ]; my ( $newM, $oldM ) = map +( stat )[ 9 ], $latest->{ file }, $oldest->{ file }; # Looks in $dirL and sets $latestL->{file} with newest file and sets $oldestL->{file} with oldest file. my ( $latestL, $oldestL ) = ( sort { $a->{ mtime } <=> $b->{ mtime } } map { { mtime => -M $_, file => $_ } } <$dirL/*> )[ 0, -1 ]; my ( $newML, $oldML ) = map +( stat )[ 9 ], $latestL->{ file }, $oldestL->{ file }; # Opens $dir and counts number of files my @files = <$dir/*>; my $fCount = @files; # Opens $dirL and counts, large files are processed seperately thus $dirL my @filesL = <$dirL/*>; my $fCountL = @filesL; # Changes Newest/Oldest file display in email based on if any files are found. if (defined($latest->{file})){ $latestF = 'Newest File: '. $latest->{file}. ' with a timestamp of '. scalar localtime $newM; $oldestF = 'Oldest File: '. $oldest->{file}. ' with a timestamp of '. scalar localtime $oldM; } # Changes Newest/Oldest file display in email based on if any large files are found. if (defined($latestL->{file})){ $latestFL = 'Newest File: '. $latestL->{file}. ' with a timestamp of '. scalar localtime $newML; $oldestFL = 'Oldest File: '. $oldestL->{file}. ' with a timestamp of '. scalar localtime $oldML; } # Looking for the lock files generated when pLock(job1) job starts to see when import started. my $pLock ='\\\\server\\E$\\directory1\\job1.lock'; my $pLockStat='No lock file for Job1 was found, this import is not currently running.'; if ( -f $pLock ) { my @time = timeconv( -M $pLock ); my $pLockWhen=$time[1].' hours, '.$time[2].' minutes, and '.$time[3].' seconds ago'; $pLockStat='Lock file found for Job2, this import was started '. $pLockWhen; } # Looking for the lock files generated when eLock(job2) job starts to see when import started. my $eLock ='\\\\server\\E$\\directory1\\job1.lock'; my $eLockStat='No lock file for Job2 was found, this import is not currently running.'; if ( -f $eLock ) { my @time2 = timeconv( -M $eLock ); my $eLockWhen=$time2[1].' hours, '.$time2[2].' minutes, and '.$time2[3].' seconds ago'; $eLockStat='Lock file found for Job2, this import was started '. $eLockWhen; }