Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

RE: Trying to display subcategories and counts

by Anonymous Monk
on May 05, 2000 at 09:52 UTC ( [id://10324]=note: print w/replies, xml ) Need Help??


in reply to Trying to display subcategories and counts

Gday, I hope this helps a little: My unerstanding is this: as you go through the file, count each occurrence of the subcategory and when you finish, display numbers for each subcategory. My example assumes stdin (so you can check it out on your file before you put it in a cgi...
while(<>) { ($categ, $subcat, $therest) = split(/|/, $_, 3); $subcatcount{$subcat}++; } foreach $subcategory (sort keys(%subcatcount)) { print "$subcategory contains $subcatcount{$subcategory}\n"; }
...should do what you want. Regards, Pat Heuvel pheuvel@optusnet.com.au

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://10324]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-24 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found