http://qs321.pair.com?node_id=10324


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