Find frequency of each word in the paragraph in perl


This article about read a text  file and count the frequency of each word in the paragraph .First we read text file and split the paragraph using space and assign into a array (@row_elements) .for every elements in (@row_elements) , increase word count (%words_count) by one . 


Perl File (read-para.pl)



Text File (para.txt)
hi , i am achchuthan . 
i like to play cricket ,
i like to watch facebook everyday .


Output of this program :
Word " , " occurs 2 Time(s)
Word " . " occurs 2 Time(s)
Word " achchuthan " occurs 1 Time(s)
Word " am " occurs 1 Time(s)
Word " cricket " occurs 1 Time(s)
Word " everyday " occurs 1 Time(s)
Word " facebook " occurs 1 Time(s)
Word " hi " occurs 1 Time(s)
Word " i " occurs 3 Time(s)
Word " like " occurs 2 Time(s)
Word " play " occurs 1 Time(s)
Word " to " occurs 2 Time(s)
Word " watch " occurs 1 Time(s)

Post a Comment

Thank you for vising

Previous Post Next Post