#!/usr/bin/perl -w
# run_phylip.pl
use strict;
my $program = shift;
my $command = shift;
my $outfile = shift;
my $outtree = shift;
$program && $command && $outfile
|| die "Usage: ./run_phylip.pl program command_file output_file [output_tree]\n";
# get rid of previous work
unlink "infile" if -e "infile";
unlink "intree" if -e "intree";
unlink "outtree" if -e "outtree";
unlink "outfile" if -e "outfile";
# run the specified program with command file
system "$program < $command > $program.out";
system "mv outfile $outfile";
system "mv outtree $outtree" if $outtree;
print "Done. Outfile saved as $outfile. Program output saved as '$program.out'\n";