sub updateMSTR { open(SEC,"pw".$prev_date.".sec")||warn("sec file not found")&& exit; open (MSTR,"c:\\lab\\PWB\\Master\\Security_Master.sec"); open( NewMSTR, ">MASTER.TMP"); while(defined($line1 = ())){ chomp($line1); $key1 = substr($line1,3,12); $key1 =~s/\s+//g; while(defined($line2 = ())){ chomp($line2); $key2 = substr($line2,3,12); $key2 =~s/\s+//g; if ("$key1" eq "$key2"){ print"$key $key2\n"; print NewMSTR "1 $line1\n"; }else{ print NewMSTR "2 $line2\n"; } } } close(MSTR); close(NewMSTR); }