#!/usr/bin/perl -w

use strict;
use lib ".";
#use Geda;
use Common;
use Pcb;
use Opt;
use Data::Dumper;

if (@ARGV < 1) { Opt::Usage("Turn a sub pcb turn upside down"); }
$OPT{prefix} = "turned_";
$OPT{suffix} = ".pcb";
Opt::opt();

for my $file (@ARGV) {
    if ($file !~ m/(.*)\.(pcb|fp)/) {
	warn("only run this program on .pcb or .fp files");
	next;
    }

    my $stem = $1;
    my @line = Common::read_file($file);
    @line = Pcb::ChSide(@line);
    my $outfile = $OPT{prefix} . $stem . $OPT{suffix};
    print "Writing to: $outfile\n";
    Common::write_file($outfile, @line);
}

__END__
