4 print STDERR "usage: $0 -oOutputFile PARM=value ...\n";
5 print STDERR " where acceptable PARM values are:\n";
6 print STDERR "\t", join(' ', @parms), "\n";
14 my %allowed_parms = ();
16 foreach $arg (@parms) { $allowed_parms{$arg} = 1; }
18 foreach $arg (@ARGV) {
20 if (defined $outfile) {
21 die "$0: Output file specified multiple times\n";
23 $outfile = substr($arg, 2);
25 my @words = split '=', $arg;
27 print STDERR "$0: $arg : #words = $#words\n";
30 if (!defined $allowed_parms{$words[0]}) {
31 print STDERR "$0: Unknown parameter $words[0]\n";
34 $parm{$words[0]} = $words[1];
39 #print "Keys defined: ", join(' ', keys %parm), "\n";
41 if (!defined $parm{$p}) {
42 die "$0: No value supplied for parameter $p\n";
44 # XXX More careful quoting of supplied value!
45 $subst .= "\t\$a =~ s|<$p>|$parm{$p}|go;\n";
47 $subst = "sub do_substitution {\n"
48 . "\tmy(\$a) = \@_;\n"
54 if (defined $outfile) {
55 open OUTFILE, ">$outfile" || die;
57 print STDERR "$0: No output file specified.\n";
61 print OUTFILE " * This file is generated, please don't edit it.\n";
62 print OUTFILE " * script: $0\n";
63 print OUTFILE " * args:\n *\t", join("\n *\t", @ARGV), "\n";
64 print OUTFILE " * The rest of this file is copied from a template, with\n";
65 print OUTFILE " * substitutions. See the template for copyright info.\n";
66 print OUTFILE " */\n";
68 print OUTFILE &do_substitution($_);