#!/usr/bin/perl --

$infile = "baseTleFile.tce";

open(INPUT, "$infile") or die "Couldn't open $infile\n";

$curSSC = 0;

# find entries where 1st and 2nd line of ssc numbers do not match
while (<INPUT>)
{
   if (substr($_, 0, 1) eq "1")
   {
       $curSSC = substr($_, 2, 5);
       $firstLine = $_;
   }
   else
   {
       if (substr($_, 2, 5) ne $curSSC)
       {
           print $firstLine;
           print $_;
       }
   }
}
close(INPUT);

print("--------------------------\n");


open(INPUT, "$infile") or die "Couldn't open $infile\n";

    $lastSSC = -10000;

    while (<INPUT>)
    {
        # check if good line
        if (substr($_, 0, 1) eq "1")
        {
            # grab the SSC number
            $curSSC = substr($_, 2, 5);
            $secondLine = <INPUT>;

            if ($curSSC <= $lastSSC)
            {
                print $_;
                print $secondLine;

                $lastSSC = $curSSC;
            }
        }
    }
close(INPUT);

exit 0;

