###########################
#  make_std.pl
#     07.08.30

use strict;
use HTML::Template;

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

my $template = HTML::Template->new(filename => 'index.html');
my @loop = ();

print "Please input the filename(*.txt)=";
chop($t{file}=<STDIN>);
$t{name} = uc($t{file});
$t{name1} = ' ' . $t{name};
if ( $t{name} eq 'ASME' ) {
    $t{name2} = 'ASTM';
    $t{name3} = 'ANSI';
    $t{name4} = 'UL';
} else {
    $t{name2}=$t{name3}=$t{name4}='XXXXXXXX';
}
if ( $t{name} eq 'EN' ) {
    $t{name4} = 'prEN';
}

$t{htmfile} = $t{file} . '.htm';
$t{file} = $t{file} . '.txt';

open(IN,"titles.txt") or die "Can't open the file titles.txt.\n";
while(<IN>){
    @fld = split;
    if ( /^TITLE/ ) {
        if ( $fld[1] eq $t{name} ) {
            $t{title} = $fld[2];
        }
    }
}
close(IN);

$template->param(title => $t{title});

open(IN,"$t{file}") or die "Can't open the file $t{file}";
while(<IN>){
    next if $. == 1;
    chomp;
    @fld = split;
    if ( /^$t{name}/ or /^$t{name1}/ or /^$t{name2}/ or /^$t{name3}/  or /^$t{name4}/ ) {
        $t{N1} = $_;
        push(@{ $t{N1s} },$t{N1});
    } elsif ( /^\t/ ) {
    } elsif ( length($_) == 0 ) {
        print "Please input one tab in $.!\n";
        exit;
    } elsif ( /^\w/ && !/^PSM/ or /^\(/) {
        $t{elist}{$t{N1}} = $_;
    } elsif ( /^PSM/ ) {
        $t{clist}{$t{N1}} = $_;
    } else {
        $t{clist}{$t{N1}} = $_;
    }
}
close(IN);

for $n ( 0 .. $#{ $t{N1s} } ) {
    $t{N1} = $t{N1s}[$n];
    $t{e1} = $t{elist}{$t{N1}};
    $t{c1} = $t{clist}{$t{N1}};
    my %row = (
            N1 => $t{N1},
            C1 => $t{c1},
            E1 => $t{e1}
    );
    push(@loop, \%row);
}

$template->param(std_loop => \@loop);
open(OUT,">$t{htmfile}");
print OUT $template->output;
close(OUT);

exit;


キムァ| 皹マェハミ| ネヌシマリ| ムヒキマリ| メヒミヒハミ| ソオア」マリ| ヨヨ゙マリ| タイィマリ| テヌ袞リ| トマ醯リ| ネヒマリ| カカカ猴ケハミ| ミ゙ヒョマリ| ユコヘマリ| ヅヤエマリ| ケンフユマリ| ニ゚フィコモハミ| チォサィマリ| ホ簓ナマリ| コヘヒカマリ| ヘウヌマリ| ネホヌハミ| ヤ貮ソマリ| ムモーイハミ| ニユクマリ| キ睛ウマリ| チノムマリ| テ鄲マリ| ヌァムマリ| フヨマリ| トスマリ| ケョチマリ| メハヒョマリ| ウ、チマリ| ク」ケアマリ| オアヘソマリ| トマタヨマリ| モタエィハミ| メヒアマリ| ヒ鄲簪リ| スェム゚ハミ|