Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Hash sort again!!

by suaveant (Parson)
on Apr 25, 2001 at 20:31 UTC ( #75527=note: print w/ replies, xml ) Need Help??


in reply to Hash sort again!!

well.. your major problem is probably that you are just using sort by itself, as though it will make your hash sorted, it won't. sort returns you a list of your sorted keys so you want

foreach (sort keys %sentance_count)
try this...
$total_sentence = @sentances; foreach $sentence (@sentences) { $count = scalar (split(/[^\w'a-zA-Z0-9_'-?]+/,$sentence)); $sentence_count{$count}++; } print ("\nThere are a total of $total_sentence sentences in this text\ +n"); foreach(keys %sentence_count) { print ("\nThere are $_ sentences of $sentence_count{$_} words\n"); }

                - Ant


Comment on Re: Hash sort again!!
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-07-04 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls