Thanks for your response Dave. The reason I am not doing SQL queries directly from Perl is that I do not have permission to access the DB directly. The person who runs the DB has created an intermediary tool that allows me to pass in SQL queries and it then sends back all the results like this:

Input:

sql_query_tool "SELECT * FROM table..."

Output:

Field1||Field2||Field3||Field4 Field1||Field2||Field3||Field4 ...

Also, I have sent my sort criteria to the DB using the query tool, and it works fine. The problem is that certain fields are blank in some cases, so it causes the sort to get screwed up in the following way:

category type1 type2 type3 1. fruit apple orange banana 2. fruit apple tangerine 3. deserts pie cake icecream

When I try to sort the fields in order of category -> type1 -> type2 -> type3 I have a problem. Sometimes the type fields can be blank. What I want is for these blank fields to be ignored by sort and the next field to be sorted on. Instead what currently happens is the blank field is sorted on which always makes it first. In the example above record 2 is missing the type2 field. When I do the sort it will put record 2 before record 1. Then when I print out the final data it will look like this:

fruit apple tangerine fruit apple orange banana

So when printed out tangerine comes before orange, because of that blank field being sorted on. This is why I came to the conclusion that I could not sort using the DB, and needed to parse the data first myself and then sort.


In reply to Re^4: Print to Less Screen by bigbot
in thread Print to Less Screen by bigbot

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.