in reply to Hash of hashes question

That last line:
print "3", keys({%termservers{$­key}}), "\n"; #doesn't work#
should be this:
print "3", keys(%{$termservers{$­key}}), "\n"; #doesn't work#

------------
:Wq
Not an editor command: Wq

Replies are listed 'Best First'.
Re: Re: Hash of hashes question
by ChrisR (Hermit) on Oct 22, 2003 at 15:39 UTC
    To make the output a little more readable:
    print "3", join( ", ", keys(%{$termservers{$key}})), "\n"; #doesn't w +ork#
    Otherwise you just get the keys printed together and it's hard to tell where one stops and the next begins.
Re: Re: Hash of hashes question
by hmerrill (Friar) on Oct 22, 2003 at 16:47 UTC
    You forgot to remove one of the two braces on the right :-)
    print "3", keys(%{$termservers{$­key}}), "\n"; should be this: print "3", keys(%{$termservers{$­key}), "\n";
      No. There are supposed to be two close-braces and one close-parenthesis. Let me spell it out:
      keys( # take the keys of a hash %{ # dereference a hashref $termservers{ # hash-table lookup $keys } # END hash-table lookup } # END hash dereference ) # END keys(

      ------------
      :Wq
      Not an editor command: Wq
        Sorry, obviously my mistake. Saw that immediately when I just looked at it again :-(