in reply to Re: count the maximum no.of occurence
in thread count the maximum no.of occurence
but output of the above code comes like this: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++; } } print "No of matching is : $n";
It is at is ais a guideis a guides a guides a guidea guide toguide to actionuide to actionide to actionde to actione to actionensures that thensures that thesures that theures that theres that thees that thes that thethat the militaryhat the militaryat the militaryt the military
Not the expected output.. What i expected is:And the maximum reference count of each word i want.. i.e in this case. "is a guide" is matched two times so its count is 2. Any suggestions.It is a is a guide is a guide a guide to guide to action ensures that the that the military
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: count the maximum no.of occurence
by jwkrahn (Abbot) on Jun 30, 2011 at 07:08 UTC | |
by sarvan (Sexton) on Jun 30, 2011 at 07:17 UTC | |
by Anonymous Monk on Jun 30, 2011 at 07:34 UTC | |
by sarvan (Sexton) on Jun 30, 2011 at 10:52 UTC | |
by sarvan (Sexton) on Jun 30, 2011 at 09:24 UTC | |
by Anonymous Monk on Jun 30, 2011 at 09:55 UTC | |
| |
by sarvan (Sexton) on Jun 30, 2011 at 07:44 UTC | |
by Anonymous Monk on Jun 30, 2011 at 08:10 UTC |