http://www.perlmonks.org?node_id=123962


in reply to Am I missing something here?

Thank you so much to everyone that contributed ideas to my question. Your input has been very valuable! Here's my solution (it's not the tightest code, but it gets the job done)

#!/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 <br>"); open(HANDLE,"../script_integration_data/script_integration_records"); while (<HANDLE>) { @temp1 = split(/:/); $domain = unpack ("A4", $temp1[40]); if (($domain eq "BBA") && ($temp1[36] eq "In Production") && ($temp +1[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_d +ate days. and $temp1[0]<br>"); # 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 "<blink><font color=\"#FF0000\">%.f days</font></blin +k>", $average; } elsif (($average >= 11) && ($average <= 44)) { print sprintf "<font color=\"#FFFF00\">%.f days</font>", $averag +e; } elsif ($average <= 10) { print sprintf "<font color=\"#669900\">%.f days</font>", $average; } sub Debug { if ( $debug ) { my $msg = shift; print $msg, "\n"; } } # EOF


-Gus I just changed up a bit by taking the absolute value instead of just getting the difference...I almost missed that, but luckily I caught it in time. Time to brush up on that 'ole math. :-)