473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to count certain words

10
Hello All!

There is a text I want to process. The name Horch appeares 4 or 5 times. The question is: how can I count the number of appearences with a Perl program?
Thank you for your answer in advance.

Gábor Szepes
Jul 31 '08 #1
5 1288
rajiv07
141 100+
Expand|Select|Wrap|Line Numbers
  1. my $val='rajiv gandhi rajiv rajiv';
  2. my $count=$val=~ s/rajiv/rajiv/g;
  3. print $count;
  4.  
try this
Jul 31 '08 #2
szepesg
10
Hello!

Thanks. It is working.

Gábor
Aug 1 '08 #3
numberwhun
3,509 Expert Mod 2GB
Expand|Select|Wrap|Line Numbers
  1. my $val='rajiv gandhi rajiv rajiv';
  2. my $count=$val=~ s/rajiv/rajiv/g;
  3. print $count;
  4.  
try this
Rajiv,

First, Please use code tags around your code that gets posted. You've been around a little while and should really know this.

Second, because this sounds like something that would be asked on homework, I personally would not have given an answer. It is this sites policy not to answer homework outright and we are not a coding service. It would have been more beneficial to the OP if he or she were asked to post the code that they have tried to do their task, rather then to just give them the code. That way, they learn something and they don't get the A+ for your work.

Regards,

Moderator
Aug 1 '08 #4
rajiv07
141 100+
Rajiv,

First, Please use code tags around your code that gets posted. You've been around a little while and should really know this.

Second, because this sounds like something that would be asked on homework, I personally would not have given an answer. It is this sites policy not to answer homework outright and we are not a coding service. It would have been more beneficial to the OP if he or she were asked to post the code that they have tried to do their task, rather then to just give them the code. That way, they learn something and they don't get the A+ for your work.

Regards,

Moderator
numberwhun,

Hereafter I wont repeat such a mistake.

Regards
Rajiv
Aug 2 '08 #5
numberwhun
3,509 Expert Mod 2GB
numberwhun,

Hereafter I wont repeat such a mistake.

Regards
Rajiv
'

Thanks! We appreciate that.

Regards,

Jeff
Aug 4 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Ling Lee | last post by:
Hi all. I'm trying to write a program that: 1) Ask me what file I want to count number of lines in, and then counts the lines and writes the answear out. 2) I made the first part like this: ...
9
by: dan | last post by:
this is a program to count average letters per word. i am able to count the total number of letters, but not words. How do you count the total number of words in a text file, so i am able to divide...
5
by: Cro | last post by:
Hello Access Developers, I'd like to know if it is possible to perform a count in an expression that defines a control source. My report is based on a query. In my report, I want a text box to...
3
by: Sashafay | last post by:
Hi, How I can count certain word in memo field? For example I have 15 words in one field and "PLUMING" word repeats in it 3 times. So I would like my code give me number three as the answer....
11
by: Foodbank | last post by:
Hello, I'm trying to develop a program that will enable me to count the number of words in a text file. As a plus, I'd like to be able to count how many different words there are too. I have a...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
9
by: aaron | last post by:
I have a few documents in which I need to get a total word count. Can anyone help? I'd like to create this program so I can get the result after entering the filename, and have the option to...
68
by: Martin Joergensen | last post by:
Hi, I have some files which has the following content: 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0
1
by: TB | last post by:
Hi there all, How do i count , using a query, the number of records in a certain table, where one of the fields has a null value, in other words only the records where the field has a null...
3
by: waynejr25 | last post by:
can anyone debug my program and get it to run. #include <fstream> #include <iostream> #include <string> #include <cstdlib> #include <map> using namespace std;
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.