I am a total newbie to perl, teaching myself so please bear that in mind!

I have a database (pipe delimited flat file) that I am accessing through CGI using a query_string eg. getoffers.cgi?Category&subcategory (eg. getoffers.cgi?Household&Alarms - this will give a list of all the alarm companies within the Household category)

The fields are in this order:
category|subcategory|company|etc|etc

I have this part working fine and displaying the offers from their respective category and sub-category within the database file.

The problem I have is that I want to be able to display the list of sub-categories and the number of offers within each in a given category by calling getoffers.cgi?Category (this would, in the case of Household list all the sub-categories like so: Alarms (3) Antiques (2) Sub-category and the number of entries with that sub-category in brackets)

I am really stuck on this, I guess I have to make an array of all the sub-categories and then count the amount of same named entries, then display only one of each.

I hope I explained this in a way that at least one of you can understand!

Thanks in advance for any help.

In reply to Trying to display subcategories and counts 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":



  • 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.