http://www.perlmonks.org?node_id=346230


in reply to Problem with hash

one way is to use a recursive sub, that 'walks' up the userid tree until it reaches a node without a manager (or a special id (like 0 or undef)

the other way is do the same as above, but use a stack and a loop

some pseudo code

# simple recursive sub sub create_users { my $user_href = shift; my $userId = shift; if(defined $user_href->{$userId} and $user_href->{$userId} != 0) { create_users($user_href, $userId); } else { return; } # now write the user to the db write_user_to_db($user_href, $userId }

I think the above should work :-)