#!/usr/local/bin/perl5 -wT print "Content-type: text/html\n\n"; $debug = 0; # Set 1 to enable debug; set to 0 to disable. use Date::Calc qw( Date_to_Days ); @Months = ('1','2','3','4','5','6','7','8','9','10','11','12'); ($Month_Day,$Month,$Year) = (localtime)[3,4,5]; $Year += 1900; $date = Date_to_Days($Year,$Month,$Month_Day); Debug (" Current date is: $date
"); open(HANDLE,"../script_integration_data/script_integration_records"); while () { @temp1 = split(/:/); $domain = unpack ("A4", $temp1[40]); if (($domain eq "BBA") && ($temp1[36] eq "In Production") && ($temp1[38] != "-") && ($temp1[38] != "--")) { $script_date = Date_to_Days($temp1[31],$temp1[30],$temp1[29]); Debug ("$temp1[31],$temp1[30],$temp1[29]"); $diff_date = abs ($date - $script_date); Debug ("script date is: $script_date and difference is: $diff_date days. and $temp1[0]
"); # If diff_date is greater than 90 days we exectue. if (($diff_date <= 90) && ($diff_date > -$diff_date)) { $sum += $temp1[38]; $count++; } } } close(HANDLE); $average = $sum / $count; if ($average >= 44) { print sprintf "%.f days", $average; } elsif (($average >= 11) && ($average <= 44)) { print sprintf "%.f days", $average; } elsif ($average <= 10) { print sprintf "%.f days", $average; } sub Debug { if ( $debug ) { my $msg = shift; print $msg, "\n"; } } # EOF