how to count certain words

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • szepesg
    New Member
    • Jul 2008
    • 10

    #1

    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
  • rajiv07
    New Member
    • Jun 2007
    • 141

    #2
    Code:
    my $val='rajiv gandhi rajiv rajiv';
    my $count=$val=~ s/rajiv/rajiv/g;
    print $count;
    try this
    Last edited by numberwhun; Aug 1 '08, 07:21 PM. Reason: Please use code tags

    Comment

    • szepesg
      New Member
      • Jul 2008
      • 10

      #3
      Hello!

      Thanks. It is working.

      Gábor

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        Originally posted by rajiv07
        Code:
        my $val='rajiv gandhi rajiv rajiv';
        my $count=$val=~ s/rajiv/rajiv/g;
        print $count;
        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

        Comment

        • rajiv07
          New Member
          • Jun 2007
          • 141

          #5
          Originally posted by numberwhun
          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

          Comment

          • numberwhun
            Recognized Expert Moderator Specialist
            • May 2007
            • 3467

            #6
            Originally posted by rajiv07
            numberwhun,

            Hereafter I wont repeat such a mistake.

            Regards
            Rajiv
            '

            Thanks! We appreciate that.

            Regards,

            Jeff

            Comment

            Working...