Matching number of syllables on right-hand and left side

I am developing a database for translating names. I have mapped through a rule engine syllables in English to syllables in Indic, delimited by an equal to sign.
An example will illustrate this

ra m= 
ku ma r=  
mo=
la l= 
gi ta= 
ka la va ti=a  a 

However it so happens that due to an error or inconsistency in syllable divisions the number of syllables on the right hand side do not match the number of syllables on the left hand side.

bo da= a  
dho dha= a 
me d r=  * 
me da= a 
ra ma b da= a   

In the first two instances 2 on the left hand, 3 on the right. In the next two, three on the left and four on the right and in the last case, four on the left and five on the right
I need a script in Perl or Awk which can identify such discrepancies and separate out the database in two files: clean and inconsistent
I work in a Windows environment but have loaded Sed also; however, I am more comfortable with Awk or Perl. The database is around 200,000 entries.
Many thanks for your help

Run as perl separate.pl gimley.example

use strict;
use warnings;

my $clean = 'clean.gmly';
my $inconsistent = 'inconsistent.gmly';

open my $clean_fh, '>', $clean or die;
open my $inconsistent_fh, '>', $inconsistent or die;

while(<>) {
  my ($lh, $rh) = split /=/;
  $lh = split /\s+/, $lh;
  $rh = split /\s+/, $rh;
  if($lh != $rh) {
    print $inconsistent_fh $_;
  }
  else {
    print $clean_fh $_;
  }
}

close $clean_fh;
close $inconsistent_fh;
1 Like

Try:

awk -F= 'split($1,F," ")!=split($2,F," "){print>f; next}1' f=file.bad file > file.good
1 Like

Many thanks for both solutions. They worked great.
Sorry for the delay