#!/usr/bin/perl -w
use Switch;
if ($#ARGV != 2 ) {
	print "source and out should be specified\n";
	exit;
}
$phone_list=$ARGV[0];

$proto=$ARGV[1];

$hmmdef=$ARGV[2];

#open F, "<", $file or die "Couldn't open $file: $!";
open(PHONE_LIST,"<$phone_list") or die "Couldn't open $phone_list";
open(PROTO,"<$proto") or die "Couldn't open $proto";
open(HMMDEF,">$hmmdef");
$proto_content="";
$valid=0;
while(<PROTO>)
{
$line=$_;
chop($line);
if ($line eq "<BEGINHMM>") {$valid=1;}
if ($valid==1){
$proto_content=$proto_content.$line."\n";
}
}
close(PROTO);
while(<PHONE_LIST>)
{
$line=$_;
chop($line);
print HMMDEF"~h \"$line\"\n$proto_content";
}
print HMMDEF"\n";
