#!/usr/bin/perl -w

if ($#ARGV != 2) {
  die "usage: makeinitopt <ranges> <weightfile> <rangefile>"
}
$s = $ARGV[0];
$woutput = $ARGV[1];
$routput = $ARGV[2];
open WOUT, ">$woutput" || die "couldn't open $woutput";
open ROUT, ">$routput" || die "couldn't open $routput";

@w = ();
@lo = ();
@hi = ();
foreach $x (split(/;/, $s)) {
  if ($x =~ /(.*),(-?[\d.]+)-(-?[\d.]+)/) {
    push(@w, $1);
    push(@lo, $2);
    push(@hi, $3);
  } else {
    print STDERR "bad weight range: $x\n";
  }
}

print WOUT join(" ", @w), "\n";
print ROUT join(" ", @lo), "\n";
print ROUT join(" ", @hi), "\n";
