lakssreedhar has asked for the wisdom of the Perl Monks concerning the following question:
i have a tab delimited column file as shown
np np n_nom 3 {RP} {RP} paNiyappeVttirunna VM_RP V_RP o o o np np n_nom -3 {/RP} {/RP} np np n_nom 3 {RP} {RP} nammal VM_RP V_RP o o o np np n_nom -3 {/RP}
and there are many such sections seperated by a new line.i want to count the no.of sentences that has {RP} {RP} and {/RP} {/RP} occuring together.If the string is missing from either the 4th or 5th column then it should not be counted.
$countC = 0; while(<>) { chomp; @array = split(/\t/,$_); if($array[4] eq $array[5]) { foreach $item(@array){ if(($item =~ /{RP}/) && ($item++ =~ /{\/RP}/)) { $countC++; } } } } print"CorrectRP=>$countC\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: compare two rows in a colum file
by moritz (Cardinal) on Aug 23, 2012 at 06:36 UTC | |
|
Re: compare two rows in a colum file
by rovf (Priest) on Aug 23, 2012 at 07:51 UTC | |
|
Re: compare two rows in a colum file
by ww (Archbishop) on Aug 23, 2012 at 12:08 UTC | |
|
Re: compare two rows in a colum file
by cheekuperl (Monk) on Aug 23, 2012 at 09:29 UTC | |
|
Re: compare two rows in a colum file
by cheekuperl (Monk) on Aug 23, 2012 at 06:14 UTC |