in reply to Re^3: subroutine memory variable scope
in thread subroutine memory variable scope
sub get_user_keys { # subfunction traverses the a hash or array reference for all of the k +eys in all tiers my $hashORarray_ref = shift @_; my %the_inputs; if (ref $hashORarray_ref eq 'HASH') { foreach ( keys %{$hashORarray_ref} ){ # print "$_ \n"; unless(defined $the_inputs{$_}){$the_inputs{$_} = 1} @the_inputs{ keys %{get_user_keys($hashORarray_ref->{$_})} } = v +alues %{get_user_keys($hashORarray_ref->{$_})}; } } if (ref $hashORarray_ref eq 'ARRAY') { for (my $i = 0; $i < scalar(@{$hashORarray_ref}); $i++) { @the_inputs{ keys %{get_user_keys($hashORarray_ref->[$i])} } = v +alues %{get_user_keys($hashORarray_ref->[$i])}; } } return(\%the_inputs); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: subroutine memory variable scope
by tobyink (Canon) on Dec 13, 2012 at 19:49 UTC |