in reply to Using a variable in place of a hash name when calling the value of a specific key
A better solution would be to use a hash-of-hashes, something like this:
Read perlref or perllol for more infomy %users = ( "Bob Smith" => { name => "Bob Smith", phone =>"123-456-7890", street =>"13245 Main Drive", city =>"Salt Lake City", state =>"Utah", zip =>"98765", }, "Jim Jones" => { name => "Jim Jones", phone =>"098-765-4321", street =>"1000 J St", city =>"Jonestown", state =>"Utah", zip =>"12345", }, ); my $user = "Jim Jones"; print "The keys for $user are: ", join(", ",keys %{$users{$user}});
|
|---|