Jeri has asked for the wisdom of the Perl Monks concerning the following question:

Hi! I'm trying to print all the values and keys of just 1 specific nested hash in a subroutine (the hash is a hash reference).

for my $protein ( keys %{$rHoH{$name}}) { print "$protein=$rHoH{$name}{$protein}"; }

It isn't working. It's throwing %rHoH requires explicit package name

I'm sure it's a novice error. I need some good reading on HoH (if you know any, throw it my way please)

Replies are listed 'Best First'.
Re: Printing only the keys and values of a single nested hash (HoH)
by keszler (Priest) on Nov 09, 2011 at 21:09 UTC

    The syntax for a hash ref is just a little different:

    for my $protein ( keys %{$rHoH{$name}}) { print "$protein=$rHoH->{$name}{$protein}"; # __ }

      Great Thanks! I also had to put -> in

       (keys %{$rHoH->{name}})