in reply to Using a variable in place of a hash name when calling the value of a specific key

kelder:

You're close: What you want is to add another layer to your hash, here are a couple hints:

my %Rolodex = { BobSmith => { name => "Bob Smith", phone =>"123-456-7890", }, JimJones => { name => "Jim Jones", phone =>"098-765-4321", }, }; for my $personKey ("BobSmith", "JimJones") { print "Name: %s, Phone: %s\n", $Rolodex{$personKey}{name}, $Rolodex{$personKey}{phone}; } my @BobSmithk = keys(%{$Rolodex{BobSmith}});
...roboticus
  • Comment on Re: Using a variable in place of a hash name when calling the value of a specific key
  • Download Code