I have written a perl script to check if the all the entries in a log file show status "--BuildSuccessful--". The Log file moves from the current folder after every successful build. It was working fine, but now sometimes its not working as expected. Below is my log file template and the script. Please suggest what I can do better?
log file template:
Build Number:: 21.9004.5200.0 BUILT TYPE:: Nightly build
===========================================================
Progress Time Build Step
BuildStarted CosmoRR Tue Apr 11 20:05:38 2017 0
CheckChanges Tue Apr 11 20:05:38 2017 0
PreBuildToolsSLN Tue Apr 11 20:14:07 2017 0
ReportDevEnvErrs Tue Apr 11 20:14:12 2017 0
CheckDevenvErrs Tue Apr 11 20:14:12 2017 0
ReplaceUCBVersionNumber Tue Apr 11 20:14:27 2017 1
BuildVPresent Tue Apr 11 20:14:27 2017 2
BuildFlashAndFlex Tue Apr 11 20:14:35 2017 3
BuildFlexTop Tue Apr 11 20:15:00 2017 4
ObfuscatePHP Tue Apr 11 20:15:07 2017 5
ReplaceSTVersionNumber Tue Apr 11 20:15:11 2017 6
BuildRubyDirector2 Tue Apr 11 21:07:52 2017 24
CreateTAPISDK Tue Apr 11 21:13:30 2017 25
BuildDMuiInstaller Tue Apr 11 21:47:51 2017 34
BuildMsiInstaller Tue Apr 11 21:47:51 2017 34
CheckSignCodeErrors Tue Apr 11 21:49:54 2017 34
CheckSignCodeErrors Tue Apr 11 21:49:54 2017 34
BuildRemoteServer Tue Apr 11 21:49:54 2017 35
BuildMsiInstaller Tue Apr 11 21:49:54 2017 35
BuildPlatformInstaller Tue Apr 11 22:13:15 2017 37
BuildMsiInstaller Tue Apr 11 22:13:15 2017 37
BuildServerInstaller Tue Apr 11 22:13:15 2017 37
BuildMsiInstaller Tue Apr 11 22:13:15 2017 37
CheckSignCodeErrors Tue Apr 11 22:59:44 2017 37
CheckSignCodeErrors Tue Apr 11 22:59:46 2017 37
CheckSignCodeErrors Tue Apr 11 22:59:46 2017 37
CheckSignCodeErrors Tue Apr 11 22:59:47 2017 37
CheckSignCodeErrors Tue Apr 11 22:59:47 2017 37
RunpostInstall Tue Apr 11 22:59:47 2017 38
ReportVersions Tue Apr 11 23:00:03 2017 39
BuildAllSims Tue Apr 11 23:00:04 2017 40
ReportSIMDevEnvErrors Tue Apr 11 23:02:41 2017 40
CheckDevenvErrs Tue Apr 11 23:02:41 2017 40
BuildAllSimsVS2010 Tue Apr 11 23:03:44 2017 41
ReportSIMDevEnvErrors Tue Apr 11 23:03:57 2017 41
CheckDevenvErrs Tue Apr 11 23:03:57 2017 41
===========================================================
--BuildSuccessful--
Successful Tue Apr 11 23:05:55 2017 41
script:
opendir DIR1, "C:\\BuildStatus\\Current\\" or die "cannot open dir $dir: $!";
my @files= grep ! /^\.+$/, readdir DIR1;
foreach my $files (@files)
{
$searchsucs = "--BuildSuccessful--";
$oldLoc2 = "C:\\BuildStatus\\Current\\".$files;
$newLocS2 = "C:\\BuildStatus\\History\\Successful\\".$files;
$newLocF2 = "C:\\BuildStatus\\History\\Failed\\".$files;
open(E_FILE,"C:\\BuildStatus\\Current\\".$files);
@valf2 = <E_FILE>;
my $newLoc2 = "";
foreach $searchf2 (@valf2)
{
if ($searchf2=~/$searchsucs/)
{ print "matched";
$num1 =$num1 + 1;
}else
{ print "not matched";
$num1 = $num1 + 0;
}
}
close E_FILE;
print "moving build status file......\n";
if($num1 == 1) {
fmove($oldLoc2, $newLocS2) or warn "$file Warning: Not able to move build status files \n ";
system(qq(E:\\depot\\builds\\PassedBuilds.bat));
} else {
fmove($oldLoc2, $newLocF2) or warn "$file Warning: Not able to move build status files \n ";
}
}
closedir DIR1;