Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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:
1 Flu 1 Cold 2 Diabetics 3 Typhoid 4 Measle
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.

In reply to Probelm with priority printing (hash or by an array) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-25 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found