my $words = { 'foo' => { named_property_x => 'nn', named_property_y => 'nns', }, 'bar' => { named_property_x => 'nvbg', named_property_y => 'np', }, }; my $lookup = 'foo'; print $words->{$lookup}->{'named_property_x'}; # Would print 'nn' foreach my $named_property (%{$words->{$lookup}}) { # This would print all the named properties for a specific word, in no particular order print $named_property . ':' . $words->{$lookup}->{$named_property} . "\n"; } # To add a new word and/or tag: $words->{'baz'}->{'named_property_z'} = 'nps'; # Do delete a tag delete $words->{'baz'}->{'named_property_z'}; # To check for a specific tag: if ( $words->{'baz'}->{'named_property_z'} eq 'nps' ) { ... } #### my $words = { 'foo' => { nn => 1, nns => 1, }, 'bar' => { nvbg => 1, np => 1, }, }; my $lookup = 'foo'; my $tag = 'nn'; print $words->{$lookup}->{$tag}; # Would print '1' foreach my $tag (keys %{$words->{$lookup}}) { # This would print all the tags for a specified word, in no particular order print $tag . "\n"; } # To add a new word and/or tag: $words->{'baz'}->{'nps'} = 1; # To delete a tag: delete $words->{'baz'}->{'nps'}; # To check for a specific tag: if ( $words->{'baz'}->{'nps'} ) { ... } #### my $words = { 'foo' => [ 'nn', 'nns' ], 'bar' => [ 'nvbg', 'np' ], }; my $lookup = 'foo'; print $words->{$lookup}->[0]; # Would print 'nn', the first tag foreach my $tag (@{$words->{$lookup}}) { # This would print the tags for a specified word, in the order in which they were defined print $tag . "\n"; } # To add a new word and/or tag: push @{$words->{'baz'}}, 'nps'; # To delete a tag: @{$words->{'baz'}} = grep { $_ ne 'nps' } @{$words->{'baz'}}; # To check for a specific tag: if ( grep { $_ eq 'nps' } @{$words->{'baz'}} ) { ... }