That's the problem.  'user' isn't in the first hash.  It's in the second hash.
The hash looks like $dept{customer}{user}.  I need to skip $dept{customer} and
check for $dept{customer}{user}.

Mathew
Keep up with me and what I'm up to: http://theillien.blogspot.com


[EMAIL PROTECTED] wrote:
> Hi,
> 
> I am not sure that I understand your problem.
> In General if you want to check the existence of the key "user" in the first 
> hash, you can use the following
>  if ($dept and exists($dept->{user}){ ....}else{....}
> 
> 
> Hope that helps
> 
> 
> Yaron Kahanovitch
> ----- Original Message -----
> From: "Mathew Snyder" <[EMAIL PROTECTED]>
> To: "Perl Beginners" <beginners@perl.org>
> Sent: Sunday, May 13, 2007 9:54:38 AM (GMT+0200) Auto-Detected
> Subject: Stuck on a hash referrence, kinda
> 
> 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;
> }

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


Reply via email to