in reply to count the maximum no.of occurence
You need something 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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: count the maximum no.of occurence
by sarvan (Sexton) on Jun 30, 2011 at 07:03 UTC | |
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 sarvan (Sexton) on Jun 30, 2011 at 07:44 UTC | |
|