Hi, all - I'm building a little applet to be used for a quick rate lookup; the data is not likely to change for a good few years, at which point the whole thing will be moot. Usually, I'd just pop it all into a couple of tables, do something like
select concat('Cost range is ', min(cost), '-', max(cost)) from mail_c +ost mc join mail_areas ma on mc.zone = ma.zone where ma.area between +1 and 10 and mc.weight = 12;
and be done - but out of the 10 or so proposed users, 7 will be carrying it on their laptops which will for various reasons often operate disconnected from the Web. It's also worth noting that most of these folks are not very amenable to additional software installations. Like, at all. E.g., installing MySQL, or even SQLite, would be treated with the horror befitting Amityville and such. So, the easiest thing I see would be for me to build this as a stand-alone app with no external dependencies (e.g., no MySQL installations.) In any case, the data is not huge - less than 30k for both the data sets even in text format - and looks like this:
zip area 001 2 002 2 003 2 005 3 012 6 [...]
for the first one, and
weight area cost 1 2 3.17 2 2 3.87 3 2 4.51 4 2 5.22 [...] 199 2 96.01 200 2 96.29 1 3 4.02 2 3 4.15 [...]
The key question is - how the heck do I structure this stuff? The term "look up", to me, immediately implies a hash or two... but for some reason (perhaps this freakin' cold that's got my brain running at half-speed) I'm not seeing it. Especially since there are no unique keys in the second table - it's a series of ranges from 1 to 200 with their associated areas and costs. So while I'm OK with the first one looking something like this (although a little birdie is whispering "there's a more efficient way to do this, stupid!" in my ear, I'm not seeing that at the moment either):
$areas = ( '001' => 2, '002' => 2, '003' => 2, [...] );
I have no idea what to do for the second one. Any help - mostly in the "how to structure this whole thing" sense - would be much appreciated.

In reply to Effective data structures for join-type lookups by flightdm

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.