vendredi 26 décembre 2014

Statistical information of a file using perl?


I'm new to perl


Assume I have a file named “your_id.txt”:


I Want to creates list of unique words used in the file, counts number of occurrence of each word and prints them in descending order based on number of occurrence.


for example I have this file:



hi long hi
see hi long
hi see long
long hi go


the result will be



word occurence
hi 5
long 4
see 2
go 1


How can I acheive this using sort() and split() in perl?


(Note: words are not case sensitive).



Aucun commentaire:

Enregistrer un commentaire