Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Trying to display subcategories and counts

by turnstep (Parson)
on May 04, 2000 at 22:29 UTC ( [id://10250]=note: print w/replies, xml ) Need Help??


in reply to Trying to display subcategories and counts

Try this:
while(<FLATFILE>) { @stuff = split(/|/, $_); push(@cats, $stuff[0]); ## Do other stuff with @cats or @stuff, and then: $subcat{$stuff[1]}++; } ## This creates a hash (%subcat) in which the keys are the subcategori +es, ## and the values are the total of each one. ## So, to output a pretty list: for $x (sort keys %subcat) { print "$x ($subcat{$x})\n"; }

This will display them in alphabetical order. From the looks of your data, this is probably desired.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found