Ok - what you have _should_ work, but there is a better solution. You should treat entries just like you treat subject - when you surround the entry index with single quotes, i assumed you really wanted a hash.

Sounds like you need to consider using a Database for this. You would have a table for students, their ID will be the primary key. You will need another table that lists the available subjects, with some unique ID for each one of those. You will need a cross-reference table to join Students with there subjects. It will consist of two fields, one for the Student ID and one for the Subject ID.

From there you will need two similar tables for the entries that links them to the proper subject.

Not using a database on a complex problem like this tends to make your code 700+ lines; using a database on a problem like this tends to make your code MUCH smaller:

select students.lname, students.fname, subjects.name, entries.name from students left join subjects on students.id = subjects.student_id left join entries on subjects.id = entries.subject_id where students.id = ? order by students.Sex, students.lname, students.fname
A wham! You now have all subjects and entries for student '?' - and they are ordered by the database, not Perl.

Databases by themselves are beyond the scope of this site, but be sure and read up on DBI.

jeffa


In reply to (jeffa) 5Re: associative array problem by jeffa
in thread associative array problem by Gerryjun

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.