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'} ) { ... }