含興奮劑目錄所列物質(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)

-------------------------------------------
返回
慈溪市| 吉木乃县| 辽中县| 华安县| 东方市| 中阳县| 钟山县| 蛟河市| 邵阳县| 启东市| 沧州市| 土默特左旗| 黄浦区| 三明市| 沈阳市| 墨竹工卡县| 彭水| 静宁县| 新兴县| 平湖市| 西乌| 六枝特区| 高密市| 景宁| 威海市| 西安市| 旅游| 许昌县| 高台县| 侯马市| 东安县| 行唐县| 右玉县| 古丈县| 连州市| 金川县| 潞西市| 青海省| 北川| 芒康县| 天水市|