Hi David, > The problem I am having is I am pulling data from a table in a > certain order and loading it into the hash array but when I read the > hash array it comes out in a different order than it is written.
When you need order and iterating, but no random access, use ARRAYs. When you need key-based random access, but no order, use HASHes. >From what you tell us, you do not need key-based access, so do not use a hash in the first place. > Key creation and hash build: If you need the key for anything (which is not even clear from what you tell us), add it to the front of your entry string. Then push the entry strings onto an ARRAY. > Reading of the hash: Just iterate the ARRAY. Besides, your sequence - select [database?] statement - linewise sprintf into CSV-like format - split while iterating looks conspiciously like it might be bad design in the first place, unless there is something you didn't tell us. If you have data in structured form and need it in structured form, keep it in structured form, don't encode it in CSV and decode it right afterwards. I strongly disagree with the statement "use Tie::IxHash" made by other contributors. Of course, you should not reinvent the wheel when you need a wheel, but you should not use non-standard packages either - unless you really need them. Maintenance will be easier the less bloat you rely on. When you really need order *and* key-based access, Tie::IxHash might be an option. But be sure not to hide bad design by pulling in overdressed tools. Yours, Ingo -- Ingo Schwarze <[EMAIL PROTECTED]> | Software Engineer | Framework Team Astaro AG | www.astaro.com | 76227 Karlsruhe | Germany _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs