How to Count words using Perl
Multidox | ForumHome | Webmasters | ( 2 ) | Stay informed | Post reply
Disclosure: This post may contain affiliate links which may earn us a commission when you click on them.
Posted by Felix on April 10, 2011 at 08:22:28:
Here is an easy way to count the number of words in a file using perl. Perl can help you know the number of words by looking at the variables from a sentence as well as the spaces in between them. I was looking for something like this and finally got it online. Here is the actual version that worked on my site.#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
my $count = 0;
while (Igbo Yoruba Hausa)
{
for (split)
{
$count++;
}
}
print "Content-type: text/html\n\n";
print "$count words!";The output: 3 words!
Comments:
Post a reply
Required fields are Name and Reply.
Recent Posts:
- Gbenga law in General: Peter Obi Vs Tinubu: Who wins southern Nigeria? - Saturday August 20, 2022 8:52:13
- Charles in General: When a Nigerian woman beats her husband - Wednesday October 7, 2020 3:32:32
- Bisi in Nigeria: Why did APC lose Edo state in 2020? - Friday September 25, 2020 15:54:55
- Chief in General: Why the long bread queues at Shoprite? - Thursday September 24, 2020 19:26:39
- Chidi in General: Why popular Nigerian banks will lose customers amidst Covid-19 pandemic - Saturday July 18, 2020 10:0:49
- James in Business: The ban of Okadas in Lagos - Saturday February 1, 2020 3:39:7
- Gbenga in General: How can Nigerians improve their life span? - Sunday June 2, 2019 20:44:31
- Felix Okoli in General: How to avoid getting cheated at Shoprite - Sunday December 3, 2017 18:56:24
- Christopher in General: Road traffic Armed robbery attacks in Lagos state and what drivers can do - Tuesday October 31, 2017 13:17:38
- Aliyu in Nigeria: What do Nigerians do during Easter? - Sunday April 16, 2017 19:45:4
- Kehinde in Nigeria: Being a whistle blower in Nigeria - Sunday April 16, 2017 19:32:53
- Hassan in Business: Can I buy things on Amazon and get it in Nigeria? - Sunday April 9, 2017 20:25:26