I don't quite understand what your code is doing. I suspect that what you are trying to do is pretty simple, but I'd need more details to give you more specific advice.
Update: OK, I made an attempt to recode what you wrote (see below). It's not exactly the same, but it should give you an idea of how to do what you want to do.
Also, as a wild guess, maybe the reason for the anomalous results you were getting is that you were inadvertently using floats as hash keys (in %Counter, etc.). The code you showed doesn't have this problem, because these hashkeys end up being all integers, but I wonder if that may have not been the case for the code that actually generated the output that you posted.
use strict; use warnings; my ( $cmd, $err ); my ( @Counter, @Tot ); my ( $time, $interval, $n_elements, @data ) = split(/,/, scalar <DATA>); my $start = my $seconds = time; for my $data ( @data ) { my $value; $seconds += $interval; if ( $interval == 60 ) { $value = sprintf("%0.2f", $data/1000); } else { $value = sprintf("%0.2f", ($data*8)/1000); } my $bin = int( ( $seconds-$start )/300 ); $Counter[ $bin ]++; $Tot[ $bin ] += $value; # etc. } use POSIX 'strftime'; my $t = int( $start/300 )*300; for my $i ( 0..$#Counter ) { my $timestring = strftime( "%m/%d/%y.%H:%M:%S", localtime( $t ) ); print join("\t", $timestring, $Counter[ $i ], $Tot[ $i ]), $/; $t += 300; } __DATA__ 07:30:04,60,750,32058,41,98,41,41,98,43,41,73,98,18050,467,428,260,363 +,836,258,1499,247,489,1208,469,633,749,439,342,258,706,817,639,2174,8 +48,909,557,876,1633,1116,1090,665,1150,817,1592,791,1741,935,675,2370 +,2039,2121,911,1955,1526,608,656,375,1488,529,376,268,1082,1858,2036, +1282,859,1356,1654,1620,2074,1546,488,2999,1564,1509,811,1427,2149,61 +1,1548,803,2313,1823,1575,1733,1168,2511,1034,2090,1491,2361,2663,206 +2,1455,957,3549,3097,2443,2680,2262,2152,2176,2645,3029,2078,1395,196 +1,801,1955,1395,1465,1030,976,1026,813,932,1745,450,1172,1457 __END__ 04/28/05.18:20:00 4 32.24 04/28/05.18:25:00 5 0.29 04/28/05.18:30:00 5 19.31 04/28/05.18:35:00 5 3.21 04/28/05.18:40:00 5 3.55 04/28/05.18:45:00 5 2.57 04/28/05.18:50:00 5 5.13 04/28/05.18:55:00 5 5.39 04/28/05.19:00:00 5 6.09 04/28/05.19:05:00 5 8.15 04/28/05.19:10:00 5 5.67 04/28/05.19:15:00 5 3.05 04/28/05.19:20:00 5 7.12 04/28/05.19:25:00 5 8.25 04/28/05.19:30:00 5 7.37 04/28/05.19:35:00 5 6.54 04/28/05.19:40:00 5 8.6 04/28/05.19:45:00 5 9.48 04/28/05.19:50:00 5 10.69 04/28/05.19:55:00 5 12.63
the lowliest monk
In reply to Re: Avoiding Datecalc
by tlm
in thread Avoiding Datecalc
by Earindil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |