Given that your disordered output is going to a single stream, it is unlikely that there is a buffering problem. Order-related buffering problems tend to apply primarily to output that involves multiple streams (e.g. STDERR and STDOUT).
Even though you think that the hashes are filled, how exactly did you determine that the output you are seeing for hash X really belongs to hash X? It seems to me that the normal way of showing that: a title, followed by a hash content dump is exactly what you are doing - and it says otherwise. Additionally, pudelli has demonstrated that when prepopulated hashes are used (without all the SQL to populate it), your code works as expected.
The SQL query within the foreach loop is pretty complicated, and that is even after you have simplified it to remove security information. So the more likely thing is that the branches that fill the various hashes aren't actually being visited in the way you expect and hence haven't been filled. Have you tried distinctive print STDERR statements at each place where you think the hash members are being added -e.g. print STDERR "filling new student reg hash key=<$key> value=<$value>"?.
BTW, no need to apologize for asking a "noob" question - the only way to "unnoob" yourself is to be a noob and ask. This is especially true when it comes to debugging - learning what to focus on takes time and happens much more quickly when we can share experiences. Thumbs up for a well formulated question.
Best, beth
In reply to Re: Printing out of order...
by ELISHEVA
in thread Printing out of order...
by kdmurphy001
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |