The only difference I see is the totals at the end. If that's the case, you should probably accumulate the totals in the first loop.
However, I rather suspect that you really don't want that. Your data shows multiple work periods for at least one employee, yet your output doesn't indicate it. I'm thinking that what you *really* want to do is to track both the number of periods *and* the total time for each employee. You might try it something like:
while (my $series = shift @series) { my $nums = shift @series; $empwork{$series}{TTL} += $nums; $empwork{$series}{CNT}++; }
Then later you can show the number of periods and the total time and compute the average.
for my $empnum (sort keys %empwork) { ... my $periods = $empwork{$empnum}{CNT}; ... }
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re^3: Perl Hash Script
by roboticus
in thread Perl Hash Script
by prithviraj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |