kens wrote: > On Jul 1, 5:40 am, [EMAIL PROTECTED] (Mathew Snyder) wrote: >> I have a script which places data 4 levels deep in a HoHoHoH. It grabs >> tickets >> in our ticket system using the systems API and places attributes about each >> piece of activity into the hash. The has is called %tickets. It looks like >> >> $tickets{action_creator}{ticket_customer}{ticket_number}{ticket_subject}. >> >> Each is self explanatory with the value under ticket_subject being the total >> time the action creator spent on the whole ticket. The actual code >> >> # gather up all of the tickets, transactions, and time for each user and >> successively place >> # all data into a HoHoH working down from user to environment to ticket >> # we go through each date in the range individually so we can make sure we >> only >> get the transactions that >> # have been added during the date range >> foreach my $date (@searchDate) { >> while (my $ticket = $tix->Next) { >> $tikSubj{$ticket->id} = $ticket->Subject; >> my $env = $ticket->FirstCustomFieldValue('Environment'); >> my $transactions = $ticket->Transactions; >> while (my $transaction = $transactions->Next) { >> my $creator = $transaction->CreatorObj; >> >> # we need to make sure the transaction is in the date >> range requested >> # it's set up like this so we can chop the timestamp >> off >> of the Created string >> (my $checkDate = $transaction->Created) =~ >> s/\s.*$//; >> >> # we only want transactions that are within the date >> range, have TimeWorked >> # set, and the creator of which is one of the actual >> users and not someone >> # that was created upon ticket submission or Cc >> addition >> next unless (($checkDate eq $date) && >> ($creator->Privileged) && ($transaction->TimeTaken)); >> >> # if all of the above stipulations are met add the >> time >> worked to the hash >> >> $tickets{$creator->Name}{$env}{$ticket->id}{$ticket->Subject} += >> $transaction->TimeTaken; >> } >> } >> >> } >> >> And the formatting >> >> foreach my $user (keys %tickets) { >> open TIMESHEET, >> ">/work_reports/ticketlists/ticketlists_$endDate/ticketlist_$user" . "_" . >> "$endDate.txt" or die "Can't open file: $!"; >> print TIMESHEET "List of tickets worked on by $user during week >> ending >> $endDate", "\n\n"; >> >> foreach my $env (sort keys %{ $tickets{$user} }){ >> >> format TIMESHEET_TOP = >> @<<<<<<<<<<<<<<<<<<<< >> $env >> Ticket ID Subject hh:mm >> ------------------------------------------------------------------ >> . >> >> write TIMESHEET_TOP; >> >> foreach my $id (sort keys %{ $tickets{$user}{$env} }) { >> foreach my $subject (keys %{ >> $tickets{$user}{$env}{$id} }) { >> format TIMESHEET = >> @######### ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>> >> $id, $tickets{$user}{$env}{$id}, >> $tickets{$user}{$env}{$id}{$subject} > > I know little about the 'format' function (never use it) but what is > it you are trying to print in the above statement? It looks to me like > you are trying to print the $id variable and then some hash > references. > > Ken >
The value under $ticket{$user}{$env}{$id}{$subject} is the total time the user spent on the ticket. >> ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >> $tickets{$user}{$env}{$id} >> . >> >> write TIMESHEET; >> } >> print TIMESHEET "\n"; >> } >> } >> >> } >> >> The problem didn't surface until I went from using the %tikSubj hash seen >> near >> the top of the code snippet to a multi-level hash. But then, using %tikSubj >> presents its own bug for some reason. >> >> Knowing that you don't know the intricacies of the system I'm working with, I >> won't be sad if no one has any input ;). >> >> Thanks >> Mathew >> -- >> Keep up with me and what I'm up to:http://theillien.blogspot.com > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/