Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Trying to display subcategories and counts

by turnstep (Parson)
on May 04, 2000 at 22:29 UTC ( #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? | Other CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2022-08-15 22:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?