#!/usr/bin/perl -w

use strict;
open(FI, "<", "bok.lytex") or die("Cannot open \"bok.lytex\"");

sub run {
  my $file = shift;
  my $part = shift;
  my $shrt = shift;

  open(FO, ">", $file) or die("Cannot open \"$file\"");
  seek FI, 0, 0;
  while(<FI>) {
    s/ZZZZ/$part/g;
    s/XXXX/$shrt/g;
    print FO $_;
  }
  close(FO);
}

&run( qw(bok.s.lytex Sopranstämma S));
&run( qw(bok.a.lytex Altstämma A));
&run( qw(bok.t.lytex Tenorstämma T));
&run( qw(bok.b.lytex Basstämma B));

&run( qw(bok.hu.lytex Sångstämmor HU));
&run( qw(bok.ae.lytex Æneas AE));

&run( qw(bok.all.lytex Partitur), "");
