If I'm working with two hashes which are actually HoH how would that work?  This
is the snippet of code I'm working with:
sub timesheet {
        my ($dept, $env) = @_;
        if (exists $dept->{username}) {
                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;
}

Does that look right?

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


Chas Owens wrote:
> On 5/12/07, Mathew Snyder <[EMAIL PROTECTED]> wrote:
>> When passing two hashes into a subroutine how do I use them separately
>> if they
>> are placed into one flat list?
>>
>> Mathew
>> -- 
>> Keep up with me and what I'm up to: http://theillien.blogspot.com
> 
> Use references:
> 
> func(\%h1, \%h2);
> 
> sub func {
>    my ($h1, $h2) = @_;
> 
>    print "h1\n";
>    for my $key (%$h1) {
>        print "$key => $h1->{$key}\n";
>    }
> 
>    print "h2\n";
>    for my $key (%$h2) {
>        print "$key => $h2->{$key}\n";
>    }
> }
> 

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


Reply via email to