Tuesday, March 11, 2014

Find frequency of each word in the paragraph in perl

Posted By: Achchuthan Yogarajah - 3/11/2014 11:18:00 PM

Share

& Comment

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)

About Achchuthan Yogarajah

I’m passionate about Web Development and Programming and I go to extreme efforts to meet my passion. I’m a believer of learning the fundamentals first. I try to understand everything little bit more than the average.

Copyright © 2016 Believe in Yourself - Achchuthan Yogarajah ACHCHUTHAN.ORG. Designed by Templateism .