Monday, September 19, 2016

Word Count in Perl

Here is a very simple program that I wrote using PERL as my programming language that will ask the user to give a sentence and then our program will count the number of words in the given sentence by the user.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.


Program Listing

#!D:\xampp\perl\bin

$wordcount = 0; 
print "\n";
print "Word Count in PERL";
print "\n\n";
print "Enter a sentence : ";
$sentence = <>;
chop ($sentence); 
@array = split(/ /,$sentence); 
$wordcount += @array; 

print "\n";   
print "Total number of words in the sentence is $wordcount."; 
print "\n\n";   
print "End of Program";
print "\n";   


No comments:

Post a Comment