Hello again, wise ones.
For the exercise and for the utility, I want to try building simple web pages from data in a flat file. Later, when I understand things better, I will use CGI.pm where appropriate. Different scripts would use differing parts of the data - not all of the data would be needed for a Name/Phone Number list, for example.

The data file would look something like this, pipe separated values (would that be PSV?) with a max of maybe 50 records instead of three. (In real life there would be many more fields, too.)

title|first|last|room|phone|email Mrs|Linda|Caralo|201|148|she@borg.org Miss|Jean|Androno|317|167|j@alo.com Mr|Steve|Paterman|101|100|steve@net.net
My question concerns using a reasonable data structure within the perl scripts. As a novice, the best I have come up with is an array of hashes as follows:
my %caralo_l ( “title” => “Mrs”, “first” => “Linda”, “last” => “Caralo”, “room” => “201”, “phone” => “148”, “email” => “she@borg.org”, ); my %androno_j ( “title” => “Miss”, “first” => “Jean”, “last” => “Andronlo”, “room” => “317”, “phone” => “167”, “email” => “j@alo.com”, ); my %paterman_s ( “title” => “Mr”, “first” => “Steve”, “last” => “Paterman”, “room” => “101”, “phone” => “100”, “email” => “stv@net.net”, ); my @alldata (%caralo_l, %androno_j, %paterman_s);
It seems to me kind of a waste to repeat the KEY information in each hash, but I haven’t thought up a better way.
Question: Is this really an array of hashes?
Question: Is this a reasonable approach?

-theo-
(so many nodes and so little time ... )
Note: All opinions are untested, unless otherwise stated


In reply to Is this a reasonable data structure? by Theo

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.