This sort of operation is what relational databases are good at. Conceptually, you would have two tables. The first one contains names, ages, and state abbreviations. The second one contains names and instrument names.
To get all of the data, you'd do a SQL JOIN command on the name fields. It might end up something like 'SELECT * FROM location, instrument JOIN ON location.name = instrument.name'. (Untested and off the top of my head.)
If you'll be doing this sort of thing often, I would highly recommend a relational database, like MySQL or PostgreSQL. If you're looking for a way of doing the same thing without a real database, DBD::RAM is a pretty cool module that'll simulate it for you.
That said, fundflow's example is an easy simple hack (in a good way), that will do only what you've described and nothing more.
I wouldn't bother trying to hack in more complexity, though, as this is a case where there's an excellent, flexible, already-coded solution. (Besides that, learning a bit about SQL and DBI will make you a more valuable programmer.)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.