A subroutine I'm working on takes two hash references.  The hashes are each
actually a HoH.

timesheet(\%opsTotal, \%opsEnvTotal);

The problem I'm having is that I need to look past the first hash and into the
second for the existence of a particular key.  I'm not sure how to go about
doing this.

sub timesheet {
        my ($dept, $env) = @_;

#This is where I need help.  'user' is in the second hash but I'm not sure how
#to get past the first one.  Should I use a foreach and step through each key?
        if (exists $dept->{user}) {
                open TIMESHEET,
">/work_reports/user/ops_timesheet_weekof_$endDate.txt";
        }else{
                open TIMESHEET,
">/work_reports/user/eng_timesheet_weekof_$endDate.txt";
        }

        print TIMESHEET "Timesheet for $startDate to $endDate\n\n\n";

        foreach my $environ (sort keys %$dept) {
                #Print the header for our data
                print TIMESHEET "$environ", "\n";
                printf TIMESHEET "%10s%8s\n", "User", "hh:mm";
                print TIMESHEET ("-" x 30);
                print TIMESHEET "\n";
                foreach my $name (sort keys %{ $dept->{$environ} }) {
                        printf TIMESHEET "%10s%8s\n", "$name",
"$dept->{$environ}->{$name}";
                }
                printf TIMESHEET ("-" x 30);
                print  TIMESHEET "\n";
                printf TIMESHEET "%18s\n\n", "$env->{$environ}";
        }
        close TIMESHEET;
}
-- 
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