#!/usr/bin/perl
while( <> )				     # for each line in the file
{
   chomp;
   @f=split(/,/,$_,2);
   if( $f[0] eq "TEMPLATE" )
   {
      $t=$f[1];
      next;
   }
   $t || die "error: TEMPLATE line needed first\n";# error checking!
   $_=$t;
   s/<([01])>/$f[$1]/g;			     # expand template against @f fields
   die "error: use of $1\n" if /(<\d>)/;
   print "$_\n";
}
