desdemona

perl malejaco

Dec 24th, 2012
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.35 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. %szatan;
  4.  
  5. open(PLIK, "<tekst.txt");
  6. while($line=<PLIK>)
  7. {
  8.     @tb=split(/[\s+,.\(\)\[\]]/ , $line);
  9.     foreach $zm(@tb)
  10.     {
  11.     $szatan{$zm}=0;
  12.     }
  13.     foreach $zm(@tb)
  14.     {
  15.     $szatan{$zm}=$szatan{$zm}+1;
  16.     }
  17. }
  18. close(PLIK);
  19.  
  20. foreach $value (sort {$szatan{$b} cmp $szatan{$a} }
  21.     keys %szatan)
  22.     {
  23.         print "$value $szatan{$value}\n"
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment