|Pathologically Eclectic Rubbish Lister
Re: Help match relevant data from three data structuresby gamache (Friar)
|on Nov 27, 2007 at 16:23 UTC
In my opinion, your best bet is to use Perl in conjunction with a relational database, via the DBI interface. Perl data structures don't represent this data ideally; there are a lot of relations here which can be expressed more clearly using a RDBMS and SQL, than in Perl using nested hashes/arrays. If you don't have a database system handy, you can grab and install DBD::SQLite, which is a small, zero-configuration SQL database system.
If you really want to do this in pure Perl, here are some tips:
Rather than having space- or pipe-separated string lists in your data structures, use array refs instead, as in:
Write a lot of intermediate functions like get_exchangetags_from_countrycode() and is_country_in_region() and write your higher-level routine in terms of these, rather than making one monolithic routine which tweaks all your data structures directly. This is called 'abstraction', and it not only frees you to think at a higher level without worrying about lower-level details, it is a godsend should you ever have to change the layout of your data structures.