#!/usr/bin/perl -w

# function to convert Placement from Plato format to Capo format

sub convert
{
# parameter: (original place, final place)
  
    open(ORIG,"< $_[0]") || die "Can't open $_[0] for input\n";
    open(OUT,"> $_[1]") || die "Can't open $_[1] for output\n";

    print OUT "UCLA pl 1.0\n\n";
    $spacing = "\t";
    while ($line = <ORIG>)
    {
	if($line =~ /[a-zA-Z0-9]+/)
	{
	    chop $line;
	    @words = split " ", $line;
	    print OUT $words[0];
	    print OUT $spacing;
	    print OUT $words[1];
	    print OUT $spacing;
	    print OUT $words[2];
	    print OUT $spacing;
	    print OUT ":  N\n";
	}
    }
  close(ORIG);
  close(OUT);
}

die "Use: convertPlatoPl2CapoPl.pl orig.place final.pl\n" if $#ARGV<0;

print "convert Placement from Plato format to Capo format.\n"; 

convert($ARGV[0], $ARGV[1]);

