467,202 Members | 1,022 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,202 developers. It's quick & easy.

how to count certain words

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
  • viewed: 1177
Share:
5 Replies
rajiv07
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
Hello!

Thanks. It is working.

Gábor
Aug 1 '08 #3
numberwhun
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
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
Expert Mod 2GB
numberwhun,

Hereafter I wont repeat such a mistake.

Regards
Rajiv
'

Thanks! We appreciate that.

Regards,

Jeff
Aug 4 '08 #6

Post your reply

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

Similar topics

22 posts views Thread by Ling Lee | last post: by
9 posts views Thread by dan | last post: by
3 posts views Thread by Sashafay | last post: by
11 posts views Thread by Foodbank | last post: by
9 posts views Thread by aaron | last post: by
68 posts views Thread by Martin Joergensen | last post: by
3 posts views Thread by waynejr25 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.