av‰υ”d?—

# business1.pl   07.07.27
use strict;
use HTML::Template;

my(%t,$n,$n1,@fld);

# Read names
open(FH,"bname.txt") or die "Can't open the file bname.txt.\n";
while(<FH>) {
    @fld = split;
    if (/^ENGLISH/ ) {
        $t{cn}{$fld[1]} = $fld[2];
        $t{e1} = $fld[3];
        for $n ( 4 .. $#fld ) {
            $t{e1} = $t{e1} . ' ' . $fld[$n];
        }
        $t{f1} = lc($fld[1]);
        $t{f2} = $t{f1} . '.txt';
        $t{f3} = $t{f1} . '.htm';
        $t{name1} = $fld[2] . '(' . $t{e1} . ')';
        push(@{ $t{txtfiles} }, $t{f2});
        push(@{ $t{htmfiles} }, $t{f3});
        push(@{ $t{names} }, $t{name1});
    }
}
close(FH);

# Read raw data and input html files
for $n ( 0 .. $#{ $t{txtfiles} } ) {
    my $template = HTML::Template->new(filename => 'ec0.htm');
    my @loop = ();

    $t{txtf1} = $t{txtfiles}[$n];
    $t{htmf1} = $t{htmfiles}[$n];
    $t{name1} = $t{names}[$n];
    $template->param(CNAME => $t{name1});

    open(FH,"$t{txtf1}") or die "Can't open the file $t{txtf1}.\n";
    while(<FH>){
        my %row = (
                    N1 => $_,
                );
        push(@loop, \%row);
    }
    close(FH);

    $template->param(ec_loop => \@loop);
    open(OUT,">$t{htmf1}");
    print OUT $template->output;
    close(OUT);
#   exit;
}

__END__