The first step in the process is to parse the the CSV. This is best done with a module such as
Text::xSV.
Then, you need to figure out how to differentiate titles from other fields. It isn't apparent from your post, so I cannot help you there.
Finally, populate the hash. A most simple-minded solution would be to create a case structure:
my @titles = ...;
if (@titles == 1) {
$BIGLIST{$title[0]} = [ @RESTOFFIELDS ];
}
elsif (@titles == 2) {
$BIGLIST{$title[0]}{$titles[1]} = [ @RESTOFFIELDS ];
}
...etc.
This works is you have some small upper bound of titles. If not, you will need a loop that walks the @title array (untested):
my @titles = ...;
my $ref = \%BIGLIST;
while (@titles > 1) {
my $title = shift @titles;
$ref = \($ref->{$title});
}
$ref->{$title[0]} = [ @RESTOFFIELDS ];
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.