# Find tentative list of abbreviations
# 1st argument: name of input file
# 2nd argument: name of output file
# 3rd argument (optional): list of flags:


if ( scalar( @ARGV ) >=  2 )
{ 
            $TheFile = $ARGV[0];
            $TheMainOutFile = ">" . $ARGV[1];
} 

 

else 
{           print  "Not enough arguments given to operate; goodbye."; 
            exit;
}


$Options = @ARGV[2];
if ( $Options =~ m/f/ ) 
{

} 
else 
{

}


open (OUTFILE, $TheMainOutFile);
open (INFILE, $TheFile) or die "The file $TheFile could not be found";

$WordCount=0;
$LineCount =0;
$Counter = 0;
$LongestWordlength =0;



while (<INFILE>)        
{

            $TheLine= $_;                               # unnecessarily explicit in real PERL
            chomp ($TheLine); 
            $LineCount =  $LineCount + 1;		

            @Words=split(/ /, $TheLine); 
            while ($Word= shift (@Words) )      
            {          $WordCount++;                
                if ( $Word =~ /\.$/ )
				{
					if ( $Word =~ /^[a-z]/ ) {  next; }
					if ( exists $PeriodWords{ $Word } )
					{

						$PeriodWords{$Word} ++;
					}
					else
					{

						$PeriodWords{$Word} = 1;
					}
				}       
						 
            }
}


print "finished reading.\n";


 


if ( $Options =~ /s/ ) 
{
 
}
else
{
 
}




@SortedList = sort {    $PeriodWords{ $b } <=> $PeriodWords { $a }    }  keys(%PeriodWords) ;


$NumberOfWords =  $#SortedList;
print "\nNumber of words: ", $NumberOfWords;  
print "\nWord Count : $WordCount";
 
while (@SortedList)
{
        $Word = shift (@SortedList);
        print OUTFILE     $Word, "\t", $PeriodWords{$Word}, "\n";

           

}

 



 
print "\nNumber of words: ", $NumberOfWords;  
print "\nWord Count : $WordCount";

  

close OUTFILE;






