realpdm

Untitled

Feb 28th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. open (FILE, "<$file") ;
  2.  
  3. my %word_counter;
  4.  
  5. while (<FILE>) {
  6. my @words_line = split(/\s/, $_) ;
  7. map { $word_counter{$_}++ } @words_line ;
  8. }
  9.  
  10. my @sorted_keys = sort { $word_counter{$b} <=> $word_counter{$a} } keys %word_counter ;
  11.  
  12. #my @sorted_keys = map { $_->[0] }
  13. #sort { $b->[1] <=> $a->[1] }
  14. #map { [$_, $word_counter{$_}] } keys %word_counter ;
Advertisement
Add Comment
Please, Sign In to add comment