#!/usr/local/bin/perl5 -w
# Execute as mactounix.pl ORGINAL PROCESSED
# ORGINAL is input file
# PROCESSED will hold processed file 
#
# Open needed files
open(ORIGINAL,$ARGV[0]) || die("\nSorry couldnt Open",$ARGV[0], "\n");
open(PROCESSED,"+>".$ARGV[1]) || die("\nSorry couldnt Create",$ARGV[1], "\n");
#
while($line=<ORIGINAL>)	{
	chomp($line);
	next unless $line;
	$rest=$line;
	$rest =~ s%\325%'%g;
	$rest =~ s%\324%'%g;
	$rest =~ s%\322%"%g;
	$rest =~ s%\323%"%g;
	$rest =~ s%\015%%g;
        $rest =~ s%\013% %g;
        $rest =~ s%\221%`%g;
        $rest =~ s%\222%'%g;
        $rest =~ s%\223%"%g;
        $rest =~ s%\224%"%g;
        $rest =~ s%\225%%g;
        $rest =~ s%\226%-%g;
        $rest =~ s%\205%...%g;
        $rest =~ s%\212%%g;
        $rest =~ s%\200%%g;
	print PROCESSED $rest,"\n";
}

#
#	Join  2 rests together returning result
#       add white space as necessary
sub join	{
	my($a,$b) = @_;
	$a = $a . ' '	if( ($a =~ /\S$/) && ($b =~ /^\S/) ) ;
	return $a . $b ;
}
