含興奮劑目錄所列物質(zhì)的藥品一覽HTML轉(zhuǎn)換程序

返回


變換程序

use strict; use HTML::Template; use utf8; my(%t,@fld,$n,$template,@loop); print "Please input filename(*.txt)="; chop($t{root}=<STDIN>); $t{inputf} = $t{root} . '.txt'; $t{htm0} = $t{root} . '0.htm'; $t{outputf} = $t{root} . '.htm'; open(IN,"name.txt") or die "Can't open the file name.txt.\n"; while(<IN>) { if ( /^8888/ ) { @fld = split; $t{d1} = $fld[1]; } } close(IN); # Read excel data @loop = (); $t{NO} = 0; open(IN,"$t{inputf}") or die "Can't open the file $t{inputf}.\n"; while(<IN>){ chop; $t{NO}++; @fld = split($t{d1}); $t{TYPE1} = 0; $t{A1} = $fld[0]; if ( $t{A1} ne "\t" ) { $t{TYPE1} = 'A1'; $t{LINE_A1}{$t{NO}} = $fld[0]; $t{LINE_B1}{$t{NO}} = $fld[1]; $t{P1} = 'P' . $t{NO}; $t{lists}{$t{P1}}++; } else { $t{lists}{$t{P1}}++; $t{LINE_B1}{$t{NO}} = $fld[1]; } if ( $t{TYPE1} ) { $t{LINE_TYPE}{$t{NO}} = $t{TYPE1}; } else { $t{LINE_TYPE}{$t{NO}} = 'A0'; } } close(IN); for $n ( 1 .. $t{NO} ) { $t{TYPE1} = $t{LINE_TYPE}{$n}; if ( $t{TYPE1} eq 'A1' ) { $t{A1} = $t{LINE_A1}{$n}; $t{P1} = 'P' . $n; $t{P1no} = $t{lists}{$t{P1}}; $t{LINE1} = '<tr bgcolor="lightcyan"><td rowspan=' . $t{P1no} . '>'; $t{LINE1} .= $t{A1} . '</td>'; $t{LINE1} .= '<td>' . $t{LINE_B1}{$n} . '</td></tr>'; } else { $t{LINE1} = '<tr bgcolor="lightcyan">'; $t{LINE1} .= '<td>' . $t{LINE_B1}{$n} . '</td></tr>'; } my %row = ( LINE1 => $t{LINE1} ); push(@loop, \%row); } $template = HTML::Template->new(filename => "$t{htm0}"); $template->param(loop => \@loop); open(OUT,">$t{outputf}"); print OUT $template->output; close(OUT); print "The output file is $t{outputf}\n"; __END__;

樣本文件1(f10.htm)

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>附件1:含興奮劑目錄所列物質(zhì)的化學(xué)藥品及生物制品品種名單</TITLE> </HEAD> <BODY bgcolor="#FFFFFF"> <center> <h2>附件1:含興奮劑目錄所列物質(zhì)的化學(xué)藥品及生物制品品種名單</h2> </center> <hr color="#003366"> <center> <table width=75% align="center" border=1 cellpadding=5> <tr bgcolor="#3399FF" align="center"> <th width=40%>興奮劑中文名</th> <th width=60%>藥品通用名稱</th> </tr> <TMPL_LOOP NAME="LOOP"> <TMPL_VAR NAME="LINE1"> </TMPL_LOOP> <tr bgcolor="#3399FF" align="center"> <th width=40%>興奮劑中文名</th> <th width=60%>藥品通用名稱</th> </tr> </table> <hr color="#003366"> </center> <a href="index.html">返回</a><br> </BODY> </HTML> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>附件2:含興奮劑目錄所列物質(zhì)的中藥品種名單</TITLE> </HEAD> <BODY bgcolor="#FFFFFF"> <center> <h2>附件2:含興奮劑目錄所列物質(zhì)的中藥品種名單</h2> </center> <hr color="#003366"> <center> <table width=75% align="center" border=1 cellpadding=5> <tr bgcolor="#3399FF" align="center"> <th width=40%>興奮劑中文名</th> <th width=60%>藥品通用名稱</th> </tr> <TMPL_LOOP NAME="LOOP"> <TMPL_VAR NAME="LINE1"> </TMPL_LOOP> <tr bgcolor="#3399FF" align="center"> <th width=40%>興奮劑中文名</th> <th width=60%>藥品通用名稱</th> </tr> </table> <hr color="#003366"> </center> <a href="index.html">返回</a><br> </BODY> </HTML>

樣本文件2(f20.htm)

-------------------------------------------
返回
阿拉善左旗| 德保县| 大冶市| 长沙市| 怀仁县| 晋城| 昂仁县| 南京市| 临高县| 鲁山县| 四平市| 庆阳市| 马尔康县| 荆州市| 那曲县| 淮南市| 云龙县| 托克托县| 二连浩特市| 辽阳县| 冷水江市| 邵阳市| 长宁县| 肇源县| 潜江市| 南投市| 南康市| 九龙坡区| 桐乡市| 宜章县| 澄城县| 武强县| 安远县| 柳河县| 四川省| 平安县| 额济纳旗| 嘉禾县| 清流县| 赤壁市| 万州区|