Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Frequency of words in text file and hashes

by deibyz (Hermit)
on Mar 18, 2005 at 11:25 UTC ( [id://440669]=note: print w/replies, xml ) Need Help??


in reply to Frequency of words in text file and hashes

Once you have the words splitted in an array, you can grab all the information from the hash. I.e.:
my $total_words = @words; #All word count my %count; $count{$_}++ for @words; # Here are the counts my $uniq_words = scalar keys %count; # Nš of uniq words # Print sorted by frequency print "$_\t$count{$_}" for (sort { $count{$b} <=> $count{$a} } keys %c +ount);

Hope it helps,
deibyz

Log In?
Username:
Password:

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

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

    No recent polls found