I don't think Data::Dumper would help in terms of inspecting the contents of the DB file. (thanks for the correction, grep) If you would like a plain-text (flat-table) dump of the DB file contents, something like this would do:
If you want something more "organized" in terms of output (e.g. sorting entries by category or by word), you could run whatever you want on the "words.txt" file, or you can the while loop above to do things other than just print out all the key/value pairs.use strict; use DB_File; # Hash with composite key strings: $words{category-word} gives count o +f # 'word' in 'category'. Tied to a DB_File to keep it persistent. my %words; tie %words, 'DB_File', 'words.db'; open( TXT, '>', 'words.txt'; while ( my ($key, $value) = each %words ) { print TXT "$key\t$value\n"; } close TXT; untie %words;
Loading the DB file contents into an in-memory data structure shouldn't be a problem for this kind of app, in case you want to do things like sorting, or working out how many categories are associated with each word, etc.
If there's something in particular you want to do with the data that you can't figure out, give us a clearer idea of what that might be (and your first try at a solution).
In reply to Re: hash function
by graff
in thread hash function
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |