On 7/2/07, Mathew <[EMAIL PROTECTED]> wrote:
foreach my $date (@searchDate) { while (my $ticket = $tix->Next) {
Seeing this worries me. I don't know enough about what's going on to tell whether it's wrong or not, but it looks wrong. When the outer loop goes on to the second iteration, what does $tix->Next yield? (You could use the debugger to find out.)
# Format the time spent on each ticket as hh:mm foreach my $user (keys %tickets) { foreach my $env (keys %{ $tickets{$user} }) { foreach my $tikID (keys %{ $tickets{$user}{$env} }) { foreach my $subject (keys %{ $tickets{$user}{$env}{$tikID} }) {
You're doing the same dereferencing, just getting deeper each time. You'll save some time if you make some of those into temporary variables. That fourth nested loop could look more like this, but possibly with better variable names: my $subjects_hash = $envs_hash->{$env}; foreach my $subject (keys %$subjects_hash) {
my @endTime; # my $temp = $tickets{$user}{$env}{$tikID}; my $temp = $tickets{$user}{$env}{$tikID}{$subject}; my $temp2 = $temp / 60; my @temp = split /\./, $temp2; $endTime[0] = $temp[0]; $endTime[1] = $temp % 60; # $tickets{$user}{$env}{$tikID} = sprintf '%d:%02d', @endTime[0,1]; $tickets{$user}{$env}{$tikID}{$subject} = sprintf '%d:%02d', @endTime[0,1];
That looks like a difficult way to do it. Maybe something like this? $subjects_hash->{$subject} = time_format($subjects_hash->{$subject}); sub time_format { my $arg = shift; return sprintf '%d:%02d', int($arg / 60), $arg % 60; } That code assumes, as did the original, that the number to be formatted is a non-negative integer of seconds or minutes. Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/