ear has asked for the wisdom of the Perl Monks concerning the following question:
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 PASSEDHere'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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Grouping by week
by Zaxo (Archbishop) on Sep 19, 2003 at 15:25 UTC | |
by ear (Acolyte) on Sep 19, 2003 at 16:09 UTC | |
|
Re: Grouping by week
by dws (Chancellor) on Sep 19, 2003 at 15:41 UTC | |
|
Re: Grouping by week
by dragonchild (Archbishop) on Sep 19, 2003 at 15:38 UTC | |
|
Re: Grouping by week
by sgifford (Prior) on Sep 19, 2003 at 15:52 UTC | |
|
Re: Grouping by week
by waswas-fng (Curate) on Sep 19, 2003 at 16:02 UTC | |
by ear (Acolyte) on Sep 19, 2003 at 16:06 UTC | |
by waswas-fng (Curate) on Sep 19, 2003 at 16:22 UTC |