Rob Dixon wrote:
> Mathew Snyder wrote:
>>
>> I have a problem printing out a hash.  This is the script I'm working
>> with:
>> #!/usr/bin/perl
>>
>> use warnings;
>> use strict;
>> use lib '/usr/local/rt-3.6.3/lib';
>> use lib '/usr/local/rt-3.6.3/local/lib';
>> use RT;
>> use RT::Tickets;
>>
>> RT::LoadConfig();
>> RT::Init();
>>
>> my $tix = new RT::Tickets(RT::SystemUser);
>> $tix->FromSQL('Queue = "CustomerCare" OR Status = "resolved" OR Status
>> = "open"');
>>
>> my $timeworked = {};
>> my %env;
>>
>> while (my $ticket = $tix->Next) {
>>         my $customer = $ticket->FirstCustomFieldValue('Environment');
>>         unless ($customer) {warn "warning" . $ticket->id. "no
>> profile"; next}
>>         my $transactions = $ticket->Transactions;
>>         while (my $transaction = $transactions->Next) {
>>                 next unless ($transaction->TimeTaken);
>>                 $timeworked =
>> $env{$transaction->Creator}{$transaction->TimeTaken};
>>                 print "Working on " . $ticket->id . "\n";
>>                 foreach my $key (keys %$env) {
>>                         print $key . " -> " . $env{$key} . "\n";
>>                 }
>>         }
>>
>> }
>>
>> When I print the hash all I get is a reference.  I can't seem to
>> figure out how
>> to get the actual contents.  I've tried using \$, %$, %{$env} and
>> %{env}.  Some
>> cause errors and some simply print out the reference.  I'm not even
>> sure I'm
>> doing the "$timeworked = " line correctly.  Can someone help me out
>> with this
>> please?
> 
> Nothing is ever put into the %env hash. If it had contents you could
> display them using
> 
>  foreach my $key (keys %env) {
>    printf "%s -> %s\n", $key, $env{$key};
>  }
> 
> but as it stands this will print nothing. I can't even work out what you
> expect to
> be in there, so I can't help you with the $timeworked assigment. Tell us
> a little
> bit more please.
> 
> Rob
> 

Essentially, this is a reporting script for our trouble ticket system.  Each
ticket has several transactions associated with it that actually make up the
ticket.  Some of those transactions are the addition of time spent on working on
the ticket by its owner.

What I am trying to do is create a hash of customers which will contain a hash
of each user and the total time spent on the customer.  First, creating the
customer hash and then, for each customer, look at its tickets and keep a
running total of time spent on the customer for each user.

Mathew

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to