?? 01_4_12_3.asp.html
字號(hào):
<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<TITLE>計(jì)算機(jī)世界網(wǎng)-Perl 語言全面編譯(五)</TITLE></HEAD>
<style>
.a14{font-size:14px;text-indent:25px;line-height:20px}
.f{font-size:18px;color=#0f3ccd}
img{border:0px;}
td,p,input{font-fammily:verdana,宋體;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>
<center>
<BODY topmargin=2 leftmargin=0>
<style>
.v12{font-size:10pt;color:"#ffffff";FONT-WEIGHT: bold}
.v14{font-size:14px;text-indent:25px;line-height:20px}
img{border:0px;}
td,p,input,select{font-fammily:verdana,宋體;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>
<style>
.v13{font-size:10pt;color:"#ffffff";FONT-WEIGHT: bold}
.v12{font-size:13px;color:"#4C029C";FONT-WEIGHT: bold}
.v14{font-size:14px;text-indent:25px;line-height:20px}
img{border:0px;}
td,p,input,select{font-fammily:verdana,宋體;font-size:12px;}
A:link {text-decoration:none;color:black}
A:visited {text-decoration:none;color:#80006f}
A:hover {text-decoration:underline;color:black}
</style>
<!--頭-->
<table align=center cellpadding="0" cellspacing="0" border="0" width="767">
<tr><td valign=bottom>
<table cellpadding="0" cellspacing="0" border=0>
<tr><td valign=top><img src="ccwlogo5.gif"></td></tr>
<tr><td height="27" valign=top><img src="knowledl.gif" width="207" height="27"></td></tr>
</table></td>
<td valign=bottom width=556 bgcolor="#4c029c" height=96>
<table cellpadding="0" cellspacing="0" border=0 width=556 bgcolor="#4c029c" height=96>
<tr><td height=25 valign=bottom bgcolor="#ffffff" colspan=2 ><img src="top00005.gif" usemap="#F"></td></tr>
<tr valign=middle >
<td align=center valign=middle height="60" align=center>
<!-- <a href="/search/" target=_blank><img src="/img2/esearch.GIF" border=0 width=468 height=60></a> --><a href="http://www.ccw.com.cn/html/search/thememail/" target=_blank><img src="topbannj.gif" border=0 width=468 height=60></a>
</td>
<td align=center width=15%>
<table width=95%>
<tr><td><a href="mailto:center@ccw.com.cn?subject=%E6%88%91%E8%A6%81%E6%8A%95%E7%A8%BF:" target=_blank><font class=v13>我要投稿</a><br><a href="mailto:center@ccw.com.cn?subject=%E7%BC%96%E8%AF%BB%E5%BE%80%E6%9D%A5"><font class=v13>編讀往來</a><br><a href="javascript:AddBookMark('計(jì)算機(jī)世界網(wǎng)首頁(yè)')"><font class=v13>加入收藏</a></font></td></tr>
</table>
</td>
</tr>
<tr><td bgcolor="#ffffff" height=1 colspan=2 ></td></tr>
<tr><td bgcolor="#b4aafc" height=2 colspan=2 ></td></tr></table>
<map name="F">
<area href="http://www.ccw.com.cn/" shape="rect" coords="29, 3, 61, 18" target=_blank>
<area href="http://www.ccw.com.cn/news1/" shape="rect" coords="72, 3, 143, 18" target=_blank>
<area href="http://www.ccw.com.cn/center/" shape="rect" coords="155, 2, 216, 18" target=_blank>
<area href="http://www.ccw.com.cn/work/" shape="rect" coords="225, 2, 299, 18" target=_blank>
<area href="http://www.ccw.com.cn/search/" shape="rect" coords="310, 3, 364, 19" target=_blank>
<area href="http://www3.ccw.com.cn/" shape="rect" coords="372, 2, 412, 19" target=_blank>
<area href="http://www2.ccw.com.cn/" shape="rect" coords="424, 2, 550, 18" target=_blank></map>
</td></tr>
<tr><td colspan=2 bgcolor="#b4aafc">
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr>
<td width=26% align=center><font class=v12>【2003年2月7日】 </font></td>
<td CLASS=V12> <a href="http://www.ccw.com.cn/center/topic.asp">專 題</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/tech.asp">技 術(shù)</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/prod.asp">產(chǎn) 品</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/app.asp">應(yīng) 用</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/net.asp">網(wǎng) 絡(luò)</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/prog.asp">編 程</a> /</td>
<td CLASS=V12><a href="http://www.ccw.com.cn/center/skill.asp">技 巧</a> </td>
</tr>
</table>
</td></tr>
</table>
<table align=center width=680>
<tr><td align=center><br><h2><font color='#0f3ccd'>Perl 語言全面編譯(五)</font></h2>
<b><a href="mailto:tanshuai@BIGFOOT.COM"><font color="#0000FF">天水-S.Tanshuai</font></a></b>
<br><hr size=1 width=660 color=#f46240></td></tr></table><br>
<table align=center width=620><tr><td class=a14><b><font size="4">第五節(jié) OOP面向?qū)ο蟮某绦蛑疄榫幾g而設(shè)計(jì)</font></b></td></tr></table><table align=center width=620><tr><td class=a14>
面向?qū)ο蟮某绦蛟O(shè)計(jì)已經(jīng)不是什么新穎的話題和技術(shù)了。它在C++和Java中,尤為重要,哎,我覺得在寫大宗程序的時(shí)候會(huì)很有幫助,但是在小程序里面反而麻煩,還不如普通的函數(shù)使用。OOP大多數(shù)基本的Perl教程都有說明,所以這里也不多講“廢話”,主要講述OOP在編譯Perl程序中的應(yīng)用以及Perl OOP編寫的技巧,所以值得一看。</td></tr></table><table align=center width=620><tr><td class=a14>
前面說過在PerlCC編譯可執(zhí)行程序的時(shí)候,不要使用require函數(shù),這是沒有錯(cuò)的。但是有很多人寫require習(xí)慣了,而且不經(jīng)常接觸OOP模式,所以不習(xí)慣。</td></tr></table><table align=center width=620><tr><td class=a14>
其實(shí)使用use比require 好很多,還有很多人用require引入變量,這是大大錯(cuò)誤,這是一種程序上編寫的失誤,所以建議以后大家不要用這種方式。編譯的時(shí)候也不要用這種放式?那么用什么方式?如果你是一個(gè)有經(jīng)驗(yàn)的Perl程序員,你應(yīng)該知道。使用OPEN函數(shù),傳送變量值。這是編譯Perl程序的關(guān)鍵,一些定量(不變的量),最好放在程序內(nèi)部,變量以及客戶所需要設(shè)置的量使用我先前說的那種方式。具體實(shí)踐方法:</td></tr></table><table align=center width=620><tr><td class=a14>
<table border="1" width="100%">
<tr>
<td width="100%" colspan="2" bgcolor="#C0C0C0"><span lang="FR" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋體;mso-font-kerning:
1.0pt;mso-ansi-language:FR;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA">Tanshuai
OpenConf </span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;
font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";mso-font-kerning:1.0pt;
mso-ansi-language:FR;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA">函數(shù)代碼:</span></td>
</tr>
<tr>
<td width="16%">
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">L.1<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">2<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">3<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">4<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">5<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">6<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">7<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">8<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">9<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">10<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">11<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">12<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">13</span></td>
<td width="84%">
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">sub Open_Conf {<o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt"><span style="mso-tab-count:1">
</span>open(FILE, "$_[0]");#</span><span style="font-size:9.0pt;mso-bidi-font-size:
12.0pt;font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-ansi-language:FR">打開~調(diào)用函數(shù)的文件名</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:12.0pt"><o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt"><span style="mso-tab-count:1">
</span>my @Conf_Info = <FILE>;#</span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;
font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"">賦予~文件內(nèi)容到</span><span lang="EN-US" style="font-size:9.0pt;
mso-bidi-font-size:12.0pt">@Conf_Info</span><span style="font-size:9.0pt;
mso-bidi-font-size:12.0pt;font-family:宋體;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"">數(shù)組中</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:12.0pt"><o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt"><span style="mso-tab-count:1">
</span>close(FILE);#</span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;font-family:宋體;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-ansi-language:
FR">關(guān)閉</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:12.0pt">~</span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;font-family:宋體;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-ansi-language:
FR">文件</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:12.0pt"><o:p>
</o:p>
</span></p>
<p class="MsoNormal" style="margin-left:3.6pt;text-indent:-3.6pt;mso-char-indent-count:
-.4;mso-char-indent-size:9.0pt"><span lang="EN-US" style="font-size:9.0pt;
mso-bidi-font-size:12.0pt"><span style="mso-spacerun: yes">
</span>my $Conf_Infos ;</span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;
font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"">定義</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt">~</span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;
font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"">局部變量</span><span lang="EN-US" style="font-size:9.0pt;
mso-bidi-font-size:12.0pt"><o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt"><span style="mso-tab-count:1">
</span>foreach $Conf_Infos (@Conf_Info) {#</span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;
font-family:宋體;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-ansi-language:FR">循環(huán)</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:12.0pt"><o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count:
2"> </span>($name,
$value) = split(/=/, $Conf_Infos);#</span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;font-family:宋體;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman"">區(qū)分~名稱和數(shù)值</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:12.0pt"><o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
12.0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count:
2"> </span>($value,
$dot) = split(/;/, $value);#</span><span style="font-size:9.0pt;mso-bidi-font-size:12.0pt;font-family:宋體;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman"">區(qū)分~結(jié)束符</span><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:12.0pt"><o:p>
</o:p>
</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-bidi-font-size:
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -