Short answer: $profit{ $facet }{ $term }{ $resource } = $url; Example:
#!perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Terse++; $Data::Dumper::Indent--; my %profit; while( <DATA> ) { chomp; my( $resource, $url, $term, $facet ) = split /,/; $profit{ $facet }{ $term }{ $resource } = $url; } print Dumper \%profit; __DATA__ asto magazine,http://oxford.edu,astronomy,subjects stars r us,http://websters.com,astronomy,subjects telescope world,http://telescope.com,astronomy,subjects 2 + 2 = 4,http://catalog.nd.edu,mathematics,subjects math library,http://worldcat.com,mathematics,subjects und,http://catalog.nd.edu,catalogs,tools worldcat,http://worldcat.com,catalogs,tools websters,http://websters.com,dictionaries,tools oxford,http://oxford.edu,dictionaries,tools On 2/10/06, Eric Lease Morgan <[EMAIL PROTECTED]> wrote: > > > On Feb 10, 2006, at 5:41 PM, Bruce Van Allen wrote: > > > foreach my $facet_key (keys %facets) { > > print "$facet_key\n"; > > my %sub_hash = %{ $facets{$facet_key} }; > > foreach my $sub_key (keys %sub_hash) { > > print "\t$sub_key\n"; > > my %inner_hash = %{ $sub_hash{$sub_key} }; > > foreach my $inner_key (keys %inner_hash) { > > print "\t\t$inner_key - $inner_hash{$inner_key}\n"; > > } > > } > > } > > > This has been VERY helpful, and I appreciate the assistance. Now I > need to programatically build the hash. > > I have this sample data structure: > > my %profile = ( > 'subjects' => { > 'astronomy' => { > 'telescope world' => 'http://telescope.com', > 'stars r us' => 'http://websters.com', > 'asto magazine' => 'http://oxford.edu' > }, > 'mathematics' => { > '2 + 2 = 4' => 'http://catalog.nd.edu', > 'math library' => 'http://worldcat.com' > } > }, > 'tools' => { > 'dictionaries' => { > 'websters' => 'http://websters.com', > 'oxford' => 'http://oxford.edu' > }, > 'catalogs' => { > 'und' => 'http://catalog.nd.edu', > 'worldcat' => 'http://worldcat.com' > } > } > ); > > > I use the followign code, based on the good work of Bruce, to > traverse %profile and output a set of nested HTML lists. It works for > any size of %profile. Fun! > > print "<ul>"; > foreach my $facet (sort(keys(%profile))) { > print "<li>$facet"; > my %facets = %{$profile{$facet}}; > print "<ul>"; > foreach my $term (sort(keys(%{$profile{$facet}}))) { > print "<li>$term"; > my %terms = %{$facets{$term}}; > print "<ol>"; > foreach my $resource (sort(keys(%terms))) { > print "<li><a href='$facets{$term}{$resource}'>$resource</ > a></li>"; > } > print "</ol>"; > print "</li>"; > } > print "</ul>"; > print "</li>"; > } > print "</ul>"; > > > I now need to build %profile programatically. As I loop through a set > of information resources I can determine the following values: > > 1. resource name (ex: telescope world) > 2. URL (ex: http://telescope.com) > 3. term (ex: astronomy) > 4. facet (ex: subjects) > > Given these values, how can I build %profile? > > -- > Eric "Perl Data Structures !R My Forte" Morgan > > > > >