Don't ask to ask, just ask | |
PerlMonks |
Probelm with priority printing (hash or by an array)by Anonymous Monk |
on Nov 06, 2008 at 14:05 UTC ( [id://721990]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
Though this is a simple problem, I am literally confused to proceed this further. I have got a list of names with their priority something like this: It has more than 15 such names. And is not from any file or any thing. I can initialize them in the code. And the numbers are the priority for each of the names. The priority may be same for different names. What I actually have to do is to query from the database for these names by their Identifiers(not the priority number) and write the result to a file. And when writing the output the result should be in the priority order. I am really confused, If using a hash I cant have the integers as a 'key' since there may be repetitive of priority number as in the example. Where as I am not sure of the way to initialize the array with both the priority number and the name associated to each other. I have a working code that fetches from the database for these name with the priority.( have used hash here with 'key' as name and 'value' as priority) But not in the given order mentioned above. Also, as the SQL query fetches from the database in anyorder its printing in the order that it fetches from the database with the priority number as 'qouted in the hash'. Any suggestions on this guys? Thank for your time and suggestions.
Back to
Seekers of Perl Wisdom
|
|