#!/usr/local/bin/perl -w

# create individual input files from the test scripts
# usage:
#   make_input.pl <prefix> <input file>

use strict;

my $count;

my $prefix = shift or die "Must specify prefix.\n";

{
  local $/ = "__DATA__\n";
  <>;
  local $/ = '--- ';
  <>;
  while (<>) {
    chomp;
    my($label, $data) = split /\n/, $_, 2;
    $data or next;
    my($in, @out) = split /^--\n/m, $data;

    $count++;
    open(FH, "> $prefix$count") or die "Can't open $prefix$count: $!\n";
    print FH $in;
  }
}
