Good Afternoon Monks,
After beating my head against my screen for a little while, I figured I'd ask those who know significantly more than me.
I've created a recursive subroutine that provides me with some results (according to the warn commands, I'm getting what I'm looking for) but the issue is that my storage array is empty when it's finished. I'm sure it's something "simple", but I can't seem to figure it out. Here's the code:
my @level; &myfunc($number, $company, \@level, 0, $dbh); print $#level; # prints -1 sub myfunc { my ($manager_no, $company_id, $level_ref, $index, $dbh) = @_; my ($employee_no, $emp_company_id); my ($sql, $sth); my @level = @$level_ref; $sql = 'query'; $sth = $dbh->prepare($sql); if ( !($sth->execute($manager_no, $company_id)) ) { die; } while ( ($employee_no, $emp_company_id) = $sth->fetchrow_array() ) + { if ( exists $level[$index]{"$employee_no-$emp_company_id"} ) { $level[$index]{"$employee_no-$emp_company_id"} = 1; } else { if ( ( $employee_no eq $manager_no) && ($emp_company_id eq $co +mpany_id) ) { # do nothing } else { $level[$index]{"$employee_no-$emp_company_id"} = "$manager_no- +$company_id"; &myfunc($employee_no, $emp_company_id, $level_ref, $index + 1, + $dbh); } } } }
If someone has a suggestion, I'd be very happy to hear it.
Thanks and all the best!
Hugh
In reply to Recursion - Array of Hashes by Heffstar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |