Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: count the maximum no.of occurence

by sarvan (Sexton)
on Jun 30, 2011 at 07:17 UTC ( [id://912119]=note: print w/replies, xml ) Need Help??


in reply to Re^3: count the maximum no.of occurence
in thread count the maximum no.of occurence

Hi jwkrahn, Again the output is something like this..
It is a t is a is a guide is a guide s a guide s a guide a guide to guide to action uide to action ide to action de to action e to action ensures that the nsures that the sures that the ures that the res that the es that the s that the that the military hat the military at the military t the military

Replies are listed 'Best First'.
Re^5: count the maximum no.of occurence
by Anonymous Monk on Jun 30, 2011 at 07:34 UTC

    Hi jwkrahn, Again the output is something like this..

    No it isn't. The code from jwkrahn produces the output you wanted. If it does not do that for you, then you are not executing that code.

      Hi,

      Sorry if i argued. Actually i did clicked the download but which takes me to plain text page where i can copy the code.

      This is how i have done.. It doesnt work in my windows perl but now i tested in ubuntu perl. its working. The output is exactly as i m expected.

      I think there may be some problem with version. Thanks for the replies..

      This is what the code suggested:
      use warnings; use strict; my $str1 = q/It is a guide to action which ensures that the military a +lways obey the commands of the party./; my $str2 = q/It is a guide to action that ensures that the military wi +ll forever heed Party commands is a guide./; my $n = 0; while ( $str1 =~ /(?=(\S+\s+\S+\s+\S+))/g ) { my $t1 = $1; while ( $str2 =~ /($t1)/g ) { print "$1\n"; $n++; } } print "No of matching is : $n\n";
      And here is the output for that:
      It is a t is a is a guide is a guide s a guide s a guide a guide to guide to action uide to action ide to action de to action e to action ensures that the nsures that the sures that the ures that the res that the es that the s that the that the military hat the military at the military t the military
      I have downloaded the code properly.

        This is what the code suggested: ...

        I have downloaded the code properly.

        Dear saravan,

        You did not download the code properly. Like I already told you in Re^7: count the maximum no.of occurence, use the download code link to download the code

        And here is the output for that:

        Simply repeating what you already said is annoying, esp when other parts of what you are saying are obviously wrong.

        Which perl are you using? I get the correct output using v5.12.2

        perldeltas says

        A pattern containing a + inside a lookahead would sometimes cause an incorrect match failure in a global match (e.g., /(?=(\S+))/g)

        #68564: /g failure with zero-width patterns

      Hi, After execution only i got the output that i showed a while ago.. Also there is an error along with the output shown:
      It is a t is a is a guide is a guide s a guide s a guide a guide to guide to action uide to action ide to action de to action e to action ensures that the nsures that the sures that the ures that the res that the es that the s that the that the military hat the military at the military t the military Quantifier follows nothing in regex; marked by <-- HERE in m/(+ <-- HE +RE lways obey the)/ at ngram1.pl line 12.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://912119]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-28 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found