I'm passing two hash references into a subroutine.  One hash is in the format of
$dept{$env}{$user}.  This contains an amount of time spent by each user on a
customer ($env).  The second hash is in the format of
$ticCount{$env}{$user}{$ticID}.  This contains a running count of how many times
a user worked on ticket '$ticID' which belongs to customer '$env'.  I won't be
using that number though.  What I need is the number of tickets worked on so I
simply use 'scalar keys' on this hash.

The problem I'm encountering though, is that I'm passing the hashes into my
subroutine as references.  When I get to the statement that gets the key count I
get an error: "Can't use string ("2") as a HASH ref while "strict refs" in use
at user_timesheet.pl line 63."  Presumably, 2 is the number of keys at
$ticCount{$env}{$user}{$ticID}.

sub average {
        my ($users, $count) = @_;
        my %userAvg;
        foreach my $env (keys %$count) {
                foreach my $user (keys %{ $count->{$env} }) {
                        foreach my $ticID (keys %{ $count->{$env}->{$user} }) {
                                my $ticCount = scalar keys %{
$count->{$env}->{$user}->{$ticID}};
                                my @meantemp;
                                my @meantime;
                                my @endtime;
                                my $temp     = $users->{$env}->{$user};
                                @meantemp    = split /\./, ($temp / $ticCount);
                                # If the time divided by the number of tickets
has a decimal
                                # value round up if that value is greater than
                                # 0.5.  This will give an even number of minutes
to figure
                                # out the mean time with.
                                if ($meantemp[1]) {
                                        if ($meantemp[1] >= 5) {
                                                $meantemp[0]++;
                                        }
                                }
                                @meantime  = split /\./, ($meantemp[0] / 60);
                                        $endtime[0]  = $meantime[0];
                                $endtime[1]  = $meantemp[0] % 60;
                                $userAvg{$env}{$user} = sprintf '%d:%02d',
@endtime[0,1];
                        }
                }
        }
        return %userAvg;
}

I've run this in the debugger and when I get to the line which assigns $ticCount
I try to print it out and it's just blank.  If I keep hitting enter it just
returns to a blank line.  I get the error when I continue to the next line with 
'c'.

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/


Reply via email to