########################### # make_std.pl # 07.08.28 use strict; use HTML::Template; my(%t,@fld,$n); my $template = HTML::Template->new(filename => 'stands.htm'); 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 'UL' ) { $t{name2} = 'ASTM'; $t{name3} = 'ANSI'; } else { $t{name2}=$t{name3}='XXXXXXXX'; } if ( $t{name} eq 'EN' ) { $t{name4} = 'prEN'; } else { $t{name4} = 'YYYYYYYYYYYYYY'; } $t{htmfile} = $t{file} . '_2.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,"./gb/$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 ( /^\w/ && !/^CZY/ && !/^Y/ or /^\(/) { $t{e1} = $_; push(@{ $t{e1s} },$t{e1}); } elsif ( /^CZY/) { $t{c1} = $_; push(@{ $t{c1s} },$t{c1}); } else { $t{c1} = $_; push(@{ $t{c1s} },$t{c1}); } } close(IN); for $n ( 0 .. $#{ $t{N1s} } ) { $t{N1} = $t{N1s}[$n]; $t{e1} = $t{e1s}[$n]; $t{c1} = $t{c1s}[$n]; 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;