I've been tasked with providing some high level data. The bosses bosses boss wants to know how we are doing week to week (meeting our SLAs or not). We have to SLAs, one for speed and one for reliability. I've been able to break down the data by day to see if we met either for that day, but having trouble figuring out how to put that into weeks. So say I start with 100% and if one day fails, that figure drops to 80% and then 60% and so on. If we miss it for the whole week then that week gets 0%. Here's a short sample of what I have been able to break down to:
07/16/03 FAILED
07/17/03 PASSED
07/18/03 FAILED
07/21/03 FAILED
07/22/03 FAILED
07/23/03 PASSED
07/24/03 PASSED
07/25/03 PASSED
07/28/03 PASSED
07/29/03 PASSED
07/30/03 PASSED
07/31/03 PASSED
08/01/03 PASSED
Here's the relevant code. I need to somehow in here instead end up with data that looks like this (those dates correspond with mondays)
07/21/03  60
07/28/03  100
08/04/03  80
and so on
open SLA, ">SLA.dat"; foreach $site (@sites) { undef %total; undef %total_time; open INPUT, "<$input_data_directory/$site\.dat" or next; while (<INPUT>) { chomp; $dataline = $_; undef @data; @data = split(/\t/); ($date,$time) = split(/\./,$data[0]); ($hour,$min) = split(/:/,$time); ($mon, $mday, $year) = split(/\//,$date); $timeinseconds = timelocal( 0, 0, 12, $mday, $mon-1, $ +year); $dayOfWeek = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime( +$timeinseconds))[6]]; next if (($dayOfWeek eq 'Sun')or($dayOfWeek eq 'Sat')) +; next if (($hour < 8) or ($hour > 19)); $total{$date}++; ### Total number of tests done per da +y shift @data; $total = 0; foreach (@data) { if (($_ eq "0")or($_ eq "0.00")) { $failed{$date}++; } $total+=$_; } $total_time{$date}+=$total; } @keys = sort keys %total; foreach (@keys) { $reliability = (int((($total{$_}-$failed{$_})/$total{$ +_})*100)*100)/100; $average = (int(($total_time{$_}/$total{$_})*100))/100 +; if (($reliability<$reliability{$site})or($average>$spe +ed{$site})) { print SLA "$_\t$site\tFAILED\n"; } else { print SLA "$_\t$site\tPASSED\n"; } } } close SLA;

In reply to Grouping by week by ear

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.