my %data = { 'CityA'=>{ 'PopByAge/Gender'=>{ 'Ages 0-9'=>{ 'Male' => 220, 'Female' => 180 }, ... }, 'FamilyHouseholds'=>{ ... }, }, ... }; #### print "What city? Choices are:\n", join(", ", sort keys %data), "\n>"; chomp($city = <>); my $hr = $data{$city}; print "What table? Choices are:\n", join(", ", sort keys %{$hr->{$city}}), "\n>"; chomp($table = <>); $hr = $hr->{$table}; print "Which group? Choices are:\n", join(", ", sort keys %{$hr->{$table}), "\n>"; chomp($grp = <>); $hr = $hr->{$grp}; ... #### # Each city may have different tables, so trawl through all the # cities to find available table names my %tables; for my $city (keys %data) { $tables{$_}{$city}=$data{$k}{$_} for keys $data{$k}; } print "Which table? Choices are:\n", join(", ", sort keys %tables), ">\n"; chomp($table=<>); print "Which city? Choices are:\n", join(", ", sort keys %{$tables{$table}}), ">\n"; chomp($city=<>); ... #### my %data = { 'PopByAge/Gender'=>{ 'Ages 0-9'=>{ 'Male'=>{ 'CityA'=>220, 'CityB'=>... } } }, ... }; #### my %data = { 'Cities'=>{ 'CityA'=>{ 'PopByAge/Gender'=>{ 'Ages 0-9'=>{'Male' = 220,'Female' = 180}, ... },... }, 'Tables'=>{ 'PopByAge/Gender'=>{ 'Ages 0-9'=>{ 'CityA'=>{'Make'=>220, 'Female'=>180}, ... ... }; #### my @data = [ { city=>'CityA', table=>'PopByAge/Gender', grpA=>'Age Group', grpB=>'Gender', A=>'0-9', B=>'Male', val=>220 }, ... ]; #### my @selected = ( @data ); while (1) { print "Search by city, table or group? (or D for done)"; chomp($key=<>); last if $key eq 'D'; my @choices = map { $_->{$key} } @data; print "Choices are: ", join(", ", sort @choices), "\n>"; } ... print report on selected data ...