#!/usr/bin/perl
#
use strict;
use warnings;

open(IN,"<", $ARGV[0]) or die "error opening $ARGV[0]\n";
open(OUT,">", "Diagnostic.ReaperLangPack") or die "error opening Diagnostic.ReaperLangPack\n";

<IN>;
print OUT "NAME:Diagnostic Template\n";

my $sec = "";
while (<IN>) {
  if (/^ *[[](.*)[]]/) {
    $sec = $1;
    print OUT $_;
    print OUT "5CA1E00000000000=1.5\n";
  }
  elsif ($sec ne "")
  {
    s/^;?[\^]*([0-9A-F]{6})([0-9A-F]{10})=(.*)/$1$2=$1:$sec $3/;
    print OUT $_;
  }
}
