If I understand your question, you just want to look at the contents of the DB file "words.db". The contents of the file are a set of key/value pairs where the keys are strings composed of a category name and a word taken from one or more input text files.

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:

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;
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.