#! /usr/bin/perl -w
# runexpF [<options>] <how_many> [<results>]
#   Assume directories starting with the current and then adding
#   "2" successively up to <how_many> exist, run in each SYNF with <options> 
#   (default, none), leaving the answers in file <results> in the given 
#   directory (default: "results").
#  
$opt = "";
OPT: for ($op=0; ; $op++) { #scan for options
  if (defined($ARGV[$op]) && $ARGV[$op] =~ "-") {
    $opt = $opt." ".$ARGV[$op];
  }
  else { last OPT; }
}
# $op is the subscript following the options (if any)
unless (defined($ARGV[0])) {die "A count must be given"; }
$N = $ARGV[$op++]; 
  #should check for reasonable number
$resfile = "results";
if (defined($ARGV[$op])) { #results file
  $resfile = $ARGV[$op];
}
chop($dir = `pwd`);
for ($i=1; $i <= $N; $i++) {
  system ("rm -f $resfile");
  system ("SYNF $opt > $resfile");
  $dir = $dir."2";
  chdir $dir;
}
