﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-weidagang2046的专栏-文章分类-Perl</title><link>http://www.blogjava.net/weidagang2046/category/8050.html</link><description>物格而后知致</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 02:01:36 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 02:01:36 GMT</pubDate><ttl>60</ttl><item><title>统计工程的源代码行数</title><link>http://www.blogjava.net/weidagang2046/articles/81406.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Wed, 15 Nov 2006 15:56:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/81406.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/81406.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/81406.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/81406.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/81406.html</trackback:ping><description><![CDATA[
		<p> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #800080">$pattern_h</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">'</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">D:/work/ChineseChess/*.h</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">'</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$pattern_cpp</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">'</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">D:/work/chineseChess/*.cpp</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">'</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$count</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">0</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">@h</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">glob</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$pattern_h</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">@cpp</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">glob</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$pattern_cpp</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">foreach</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">@h</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">open</span>
				<span style="COLOR: #000000">(FILE</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$line</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">FILE</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    {<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$count</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">foreach</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">@cpp</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">open</span>
				<span style="COLOR: #000000">(FILE</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$line</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">FILE</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    {<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #800080">$count</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$count</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">; </span>
		</div>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/81406.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-11-15 23:56 <a href="http://www.blogjava.net/weidagang2046/articles/81406.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Perl eval函数探讨</title><link>http://www.blogjava.net/weidagang2046/articles/66028.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Sun, 27 Aug 2006 13:03:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/66028.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/66028.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/66028.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/66028.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/66028.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Verdana">2006-8-27</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
								<font face="Verdana"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 10pt">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">作为一种脚本语言可以实时地生成和执行代码。这种特性可以把代码的编译推迟到运行时，所以又称为“动态代码”。另外，</span>
				<span lang="EN-US">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">也如</span>
				<span lang="EN-US">
						<font face="Verdana">Java</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">、</span>
				<span lang="EN-US">
						<font face="Verdana">C++</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">一样提供了异常处理机制。本文将初步探讨</span>
				<span lang="EN-US">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中实现动态代码和异常处理机制的函数：</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">。如有错误不足，欢迎讨论和批评指正。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Verdana"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">函数可以看作是</span>
				<span lang="EN-US">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">虚拟机，它的参数就是一段</span>
				<span lang="EN-US">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">代码。利用</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt">
						<font face="Verdana">’perldoc –f eval’</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">可以获取</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">函数使用帮助，其中介绍了它的两种使用方式：</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Verdana"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt">
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">l<span style="FONT: 7pt 'Times New Roman'">         </span></span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt">
						<font face="Verdana">eval EXPR<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Verdana">EXPR</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是一个的表达式，例如：</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">eval</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"print $a"</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">;</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">eval</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">'print $a'</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> . </span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">', $b'</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">;</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">eval</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">1</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">+</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">3</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">;</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">eval</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">'print '</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> . </span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">'$a + $b, "\n"'</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">;</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">eval</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">$<span style="COLOR: #a000f0">command;</span><span style="COLOR: black"></span><span style="COLOR: #b20022">#$command = ‘print “hello Perl”’</span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">eval</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">$<span style="COLOR: #a000f0">ARGV[</span><span style="COLOR: #a02000">0</span><span style="COLOR: black">];<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">在执行时，</span>
				<span lang="EN-US">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">解释器会首先解析表达式的值，然后将表达式值作为一条</span>
				<span lang="EN-US">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">语句插入当前执行上下文。所以，新生成的语句与</span>
				<span lang="EN-US">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">语句本身具有相同的上下文环境。这种方式中，每次执行</span>
				<span lang="EN-US">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">语句，表达式都会被解析。所以，如果</span>
				<span lang="EN-US">
						<font face="Verdana">eval EXPR</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">如果出现在循环中，表达式可能会被解析多次。</span>
				<span lang="EN-US">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的这种方式使得</span>
				<span lang="EN-US">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">脚本程序能实时生成和执行代码，从而实现了“动态代码”。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Verdana"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt">
				<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings">
						<span style="mso-list: Ignore">l<span style="FONT: 7pt 'Times New Roman'">         </span></span>
				</span>
				<span lang="EN-US" style="FONT-SIZE: 10pt">
						<font face="Verdana">eval BLOCK<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Verdana">BLOCK</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">是一个代码块，例如：</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Verdana">eval {print $a};</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font face="Verdana">eval {$a = 1, $b = 2, $c = $a + $b};</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">与第一种方式不同，</span>
				<span lang="EN-US">
						<font face="Verdana">BLOCK</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">只会被解析一次，然后整个插入当前</span>
				<span lang="EN-US">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">函数所在的执行上下文。由于解析上的性能的优势，以及可以在编译时进行代码语法检查，这种方式通常被作为</span>
				<span lang="EN-US">
						<font face="Verdana">Perl</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">用来为一段代码提供异常捕捉机制，虽然前一种方式也可以。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="COLOR: navy">
						<o:p>
								<font face="Verdana"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">按帮助的名称，称</span>
				<span lang="EN-US">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的参数程序为“小程序”</span>
				<span lang="EN-US">
						<font face="Verdana">(mini-proggram)</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">。在两种方式中，</span>
				<span lang="EN-US">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">函数的返回值都是小程序的最后一条语句的值，如果遇到</span>
				<span lang="EN-US">
						<font face="Verdana">return</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">语句，与子例程相同。</span>
		</p>
		<div align="center">
				<table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellspacing="0" cellpadding="0" width="100%" border="1">
						<tbody>
								<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" valign="top" width="100%">
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
														<b style="mso-bidi-font-weight: normal">
																<span lang="EN-US" style="COLOR: #ff9900">
																		<font face="Verdana">Script1:<o:p></o:p></font>
																</span>
														</b>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b20022; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">#!/usr/bin/perl -w</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p> </o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">push</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">(</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">@<span style="COLOR: #a000f0">program,</span><span style="COLOR: black"></span><span style="COLOR: blue">'$i = 1;'</span><span style="COLOR: black">);</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">push</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">(</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">@<span style="COLOR: #a000f0">program,</span><span style="COLOR: black"></span><span style="COLOR: blue">'$i = 3; $j = 2; $k = $i + $j'</span><span style="COLOR: black">);</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">push</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">(</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">@<span style="COLOR: #a000f0">program</span><span style="COLOR: black">, </span><span style="COLOR: blue">'$i = 3; return 24; $k = $i + $j'</span><span style="COLOR: black">);</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p> </o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">foreach</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">exp </span><span style="COLOR: black">(</span>@<span style="COLOR: #a000f0">program)</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">{</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">rtn </span><span style="COLOR: #b22200">=</span><span style="COLOR: black"></span><span style="COLOR: #a020f0">eval</span><span style="COLOR: black">(</span>$<span style="COLOR: #a000f0">exp)</span><span style="COLOR: black">;</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">print</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">rtn,</span><span style="COLOR: black"></span><span style="COLOR: blue">"\n"</span><span style="COLOR: black">;</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">}</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
														<b style="mso-bidi-font-weight: normal">
																<span lang="EN-US" style="COLOR: #ff9900">
																		<font face="Verdana">Output:<o:p></o:p></font>
																</span>
														</b>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
														<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Courier New'">1<o:p></o:p></span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
														<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Courier New'">5<o:p></o:p></span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
														<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Courier New'">24</span>
														<span lang="EN-US" style="COLOR: navy">
																<o:p>
																</o:p>
														</span>
												</p>
										</td>
								</tr>
						</tbody>
				</table>
		</div>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Verdana"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">如果小程序中有语法错误、运行时错误遇到</span>
				<span lang="EN-US">
						<font face="Verdana">die</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">语句，</span>
				<span lang="EN-US">
						<font face="Verdana">eval</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">将返回</span>
				<span lang="EN-US">
						<font face="Verdana">undef</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">。错误码被保存在</span>
				<span lang="EN-US">
						<font face="Verdana">$@</font>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中。</span>
		</p>
		<div align="center">
				<table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellspacing="0" cellpadding="0" width="100%" border="1">
						<tbody>
								<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
										<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" valign="top" width="100%">
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left">
														<b style="mso-bidi-font-weight: normal">
																<span lang="EN-US" style="COLOR: #ff9900">
																		<font face="Verdana">Script2:<o:p></o:p></font>
																</span>
														</b>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b20022; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">#!/usr/bin/perl -w</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p> </o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">push</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">(</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">@<span style="COLOR: #a000f0">program</span><span style="COLOR: black">, </span><span style="COLOR: blue">'$i = 3; die "error message"; $k = $i + $j'</span><span style="COLOR: black">);</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p> </o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">foreach</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">exp </span><span style="COLOR: black">(</span>@<span style="COLOR: #a000f0">program)</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">{</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">rtn </span><span style="COLOR: #b22200">=</span><span style="COLOR: black"></span><span style="COLOR: #a020f0">eval</span><span style="COLOR: black">(</span>$<span style="COLOR: #a000f0">exp)</span><span style="COLOR: black">;</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">if</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">(</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">!</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">defined</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">(</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">rtn)</span><span style="COLOR: black">)</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">{</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 2">       </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">print</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">"Exception: "</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">, </span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">@,</span><span style="COLOR: black"></span><span style="COLOR: blue">"\n"</span><span style="COLOR: black">;</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">}</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">else</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">{</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 2">       </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">print</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">rtn,</span><span style="COLOR: black"></span><span style="COLOR: blue">"\n"</span><span style="COLOR: black">;</span></span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
																<span style="mso-tab-count: 1">    </span>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">}</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b22200; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">}</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">;</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p> </o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left">
														<b style="mso-bidi-font-weight: normal">
																<span lang="EN-US" style="COLOR: #ff9900">
																		<font face="Verdana">Output:<o:p></o:p></font>
																</span>
														</b>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left">
														<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: navy; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">Exception: error message at (eval 1) line 1.</span>
														<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
																<o:p>
																</o:p>
														</span>
												</p>
												<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left">
														<span lang="EN-US">
																<o:p>
																		<font face="Verdana"> </font>
																</o:p>
														</span>
												</p>
										</td>
								</tr>
						</tbody>
				</table>
		</div>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font face="Verdana"> </font>
						</o:p>
				</span>
		</p>
		<table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellspacing="0" cellpadding="0" width="100%" border="1">
				<tbody>
						<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
								<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" valign="top" width="100%">
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
												<b style="mso-bidi-font-weight: normal">
														<span lang="EN-US" style="COLOR: #ff9900">
																<font face="Verdana">Script3:<o:p></o:p></font>
														</span>
												</b>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b20022; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">#!/usr/bin/perl -w</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
														<o:p>
														</o:p>
												</span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
														<o:p> </o:p>
												</span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b20022; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white"># a run-time error</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
														<o:p>
														</o:p>
												</span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a020f0; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">eval</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
												</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">'$answer ='</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">;<span style="mso-spacerun: yes">   </span></span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #b20022; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white"># sets $@</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
														<o:p>
														</o:p>
												</span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #a02000; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">warn</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">
												</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">$<span style="COLOR: #a000f0">@ </span><span style="COLOR: #a020f0">if</span><span style="COLOR: black"></span>$<span style="COLOR: #a000f0">@;</span></span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
														<o:p>
														</o:p>
												</span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
												<span lang="EN-US" style="COLOR: navy">
														<o:p>
																<font face="Verdana"> </font>
														</o:p>
												</span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
												<b style="mso-bidi-font-weight: normal">
														<span lang="EN-US" style="COLOR: #ff9900">
																<font face="Verdana">Output:<o:p></o:p></font>
														</span>
												</b>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
												<span lang="EN-US" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: navy; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt; mso-highlight: white">syntax error at (eval 1) line 2, at EOF</span>
												<span lang="EN-US" style="COLOR: navy">
														<o:p>
														</o:p>
												</span>
										</p>
								</td>
						</tr>
				</tbody>
		</table>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US" style="COLOR: navy">
						<o:p>
								<font face="Verdana"> </font>
						</o:p>
				</span>
		</p>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/66028.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-27 21:03 <a href="http://www.blogjava.net/weidagang2046/articles/66028.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何捕捉CGI程序exception</title><link>http://www.blogjava.net/weidagang2046/articles/65888.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Sat, 26 Aug 2006 01:07:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/65888.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/65888.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/65888.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/65888.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/65888.html</trackback:ping><description><![CDATA[
		<p>用perl写cgi程序的时候，如果出现了问题，大多数都必须查看Web server的日志才能知道程序哪里出了错误，页面一般只返回500服务器错误，不能立刻获得错误的原因。</p>
		<p>使用php的程序员就没有这个烦恼，因为php默认会将错误都打印到页面上。CGI程序里如何才能做到这一点呢？</p>
		<p>
				<span class="caps">CGI</span>::Carp这个模块支持这个功能，以下是例子：</p>
		<pre>
				<code>
						<span class="category1">use</span> CGI::Carp <span class="category3">qw</span>(fatalsToBrowser);
<span class="category2">die</span> "Bad error here";</code>
		</pre>
		<p>详细请参阅<a href="http://search.cpan.org/~lds/CGI.pm-3.09/CGI/Carp.pm"><span class="caps">CGI</span>::Crap</a>的在线手册</p>
		<p>那如果是自己写的简单CGI程序，不使用CGI.pm怎么办？以下是简单的方法......</p>
		<div id="a000035more">
				<div id="more">
						<h4>原理简述</h4>Perl 提供了%SIG 这个特殊的HASH，通过定义信号响应函数，可以捕捉die及一些warning的信息，并将这些信息打印到web页上。但为了尽可能早的加载这些代码，最好将信号捕捉代码放到BEGIN块中，这样就能保证程序一执行就先执行异常捕捉这段代码了。 <pre><code><span class="category3">BEGIN</span> {
     <span class="linecomment"># fatal handler setting.</span>
     $SIG{__DIE__} = $SIG{__WARN__} = \&amp;some_func;
}</code></pre><h4>代码例子</h4>以下是一个简单的例程，定义了一个叫handler_fatal处理函数来处理意外错误信息。 <pre><code><span class="linecomment">#!/usr/bin/perl -w</span><span class="category1">use</span> strict

<span class="category3">BEGIN</span> {
     <span class="linecomment"># fatal handler setting.</span>
     $SIG{__DIE__} = $SIG{__WARN__} = \&amp;handler_fatal;
}
<span class="linecomment"># some perl code goes here</span>
......

<span class="category1">sub</span> handler_fatal {
     <span class="category2">print</span> "Content-type: text/html\n\n";
     <span class="category2">print</span> "@_";
}</code></pre><p>上面这段perl程序中，如果调用一个名称为abc();的子例程，浏览器将看到如下的错误信息：</p><pre>Undefined subroutine &amp;main::abc called at /home/hzqbbc/cgi-bin/fatal.cgi line 8.
</pre><p>通过这个方法就可以很简便的进行程序调试了。Extmail中的CGI.pm就是使用类似的方法，可以捕捉die(), warn() 等函数产生的错误及系统的错误提示。<br /><br />from: <a href="http://www.hzqbbc.com/blog/arch/2005/05/aecgicexception.html">http://www.hzqbbc.com/blog/arch/2005/05/aecgicexception.html</a></p></div>
		</div>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/65888.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-26 09:07 <a href="http://www.blogjava.net/weidagang2046/articles/65888.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>创建或删除目录</title><link>http://www.blogjava.net/weidagang2046/articles/65250.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Wed, 23 Aug 2006 04:50:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/65250.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/65250.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/65250.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/65250.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/65250.html</trackback:ping><description><![CDATA[
		<font face="Verdana">
				<font size="2">File::Path module中的：<br /><br /><span class="i">mkpath</span><span class="s">(</span><span class="s">[</span><span class="q">'/foo/bar/baz'</span><span class="cm">,</span><span class="q">'blurfl/quux'</span><span class="s">]</span><span class="cm">,</span><span class="n">1</span><span class="cm">,</span><span class="n">0711</span><span class="s">)</span><span class="sc">;</span><br /><span class="i">rmtree</span><span class="s">(</span><span class="s">[</span><span class="q">'foo/bar/baz'</span><span class="cm">,</span><span class="q">'blurfl/quux'</span><span class="s">]</span><span class="cm">,</span><span class="n">1</span><span class="cm">,</span><span class="n">1</span><span class="s">)</span><span class="sc">;</span></font>
		</font>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/65250.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-23 12:50 <a href="http://www.blogjava.net/weidagang2046/articles/65250.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Perl Tips 2006/8/19</title><link>http://www.blogjava.net/weidagang2046/articles/64542.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Sat, 19 Aug 2006 11:39:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/64542.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/64542.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/64542.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/64542.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/64542.html</trackback:ping><description><![CDATA[
		<font face="Verdana" size="2">2 Perl language tips are met today.<br /><br />1. a code snippet is as follows:<br /> <br />$code[$idx] =~ /^\s*(.+?)\s*$/;<br />$code[$idx] = $1;<br /><br />Seem it's to extract the content without leading and tailing white space. But the (.+?) is still not understood.<br /><br />2. a code snippet is as follows:<br /><br />my $currentframe;<br />$currentframe = {<br /> _pc_ =&gt; 0,<br /> _func_ =&gt; 'main'<br /> };<br /><br />what's the type of $currentframe? handle to a hashtable? </font>
		<br />
		<br />
		<font face="Verdana" size="2">Answer: $currentframe is a reference to an anonymous hash. Usage: $$currentframe{_pc_} or $currentframe-&gt;{_pc_}</font>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/64542.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-19 19:39 <a href="http://www.blogjava.net/weidagang2046/articles/64542.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>删除用通配符匹配的一类文件</title><link>http://www.blogjava.net/weidagang2046/articles/64224.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Thu, 17 Aug 2006 15:28:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/64224.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/64224.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/64224.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/64224.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/64224.html</trackback:ping><description><![CDATA[
		<font face="Verdana">
				<span style="FONT-SIZE: 13px">unlink 可以用通配符<br /><br />       unlink LIST<br />       unlink  Deletes a list of files.  Returns the number of files success-<br />               fully deleted.<br /><br />                   $cnt = unlink ’a’, ’b’, ’c’;<br />                   unlink @goners;<br />                   <strong><font color="#cc0000">unlink &lt;*.bak&gt;;</font></strong><br /><br />               Note: "unlink" will not delete directories unless you are supe-<br />               ruser and the -U flag is supplied to Perl.  Even if these con-<br />               ditions are met, be warned that unlinking a directory can<br />               inflict damage on your <font color="#000000">filesystem</font>.  Use "rmdir" instead.<br /><br />               If LIST is omitted, uses $_.</span>
		</font>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/64224.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-17 23:28 <a href="http://www.blogjava.net/weidagang2046/articles/64224.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>列出目录下的所有子目录和文件名</title><link>http://www.blogjava.net/weidagang2046/articles/63516.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Mon, 14 Aug 2006 09:36:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/63516.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/63516.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/63516.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/63516.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/63516.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">#</span>
				<span style="COLOR: #008000">!/usr/bin/perl -w</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #800080">@files</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">d</span>
				<span style="COLOR: #000000">:/*&gt;</span>
				<span style="COLOR: #000000">;<br /><br /></span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">join</span>
				<span style="COLOR: #000000">(</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">\n------\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">@files</span>
				<span style="COLOR: #000000">);<br /></span>
		</div>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/63516.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-14 17:36 <a href="http://www.blogjava.net/weidagang2046/articles/63516.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>perl自带的介绍图形界面的例子</title><link>http://www.blogjava.net/weidagang2046/articles/62958.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Fri, 11 Aug 2006 04:21:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/62958.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/62958.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/62958.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/62958.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/62958.html</trackback:ping><description><![CDATA[
		<p>运行widget命令</p>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/62958.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-11 12:21 <a href="http://www.blogjava.net/weidagang2046/articles/62958.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>windows 下的system命令的后台运行求助</title><link>http://www.blogjava.net/weidagang2046/articles/62878.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Thu, 10 Aug 2006 15:04:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/62878.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/62878.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/62878.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/62878.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/62878.html</trackback:ping><description><![CDATA[
		<div class="article" id="art31029">
				<div class="article" id="art31029">发信人: cm3 (cm3), 信区: Perl<br />标  题: windows 下的system命令的后台运行求助<br />发信站: 水木社区 (Thu Aug 10 14:45:04 2006), 站内<br /><br />在linux下，可以用system("abc.exe -s=com1 &amp;");来让abc.exe后台运行。<br />但在windows下，安装了activeperl，怎么来实现类似与上面的后台运行？谢了！！！<br /><br />--<br /><br />※ 来源:·水木社区 newsmth.net·[FROM: 219.237.6.*]<br /></div>
				<br />
				<div class="tconPager smaller left">[<a href="http://www.smth.org/bbscon.php?bid=226&amp;id=31031"><font color="#002c99">本篇全文</font></a>] [<a href="http://www.smth.org/bbspst.php?board=Perl&amp;reid=31031"><font color="#002c99">回复文章</font></a>] [本篇作者：<a href="http://www.smth.org/bbsqry.php?userid=qcpassed"><font color="#002c99">qcpassed</font></a>] [<a href="http://www.smth.org/bbspstmail.php?board=Perl&amp;id=31031"><font color="#002c99">回信给作者</font></a>] [<a href="http://www.smth.org/bbsdoc.php?board=Perl"><font color="#002c99">进入讨论区</font></a>] [<a href="http://www.smth.org/bbstcon.php?board=Perl&amp;gid=31029#top"><font color="#002c99">返回顶部</font></a>] 
<div class="tnum">2</div></div>
				<div class="article" id="art31031">发信人: qcpassed (xiaoqiao), 信区: Perl<br />标  题: Re: windows 下的system命令的后台运行求助<br />发信站: 水木社区 (Thu Aug 10 14:57:43 2006), 站内<br /><br />看看system("start abc.exe -s=com1 ");行么<br />【 在 cm3 (cm3) 的大作中提到: 】<br /><span class="f006">: 在linux下，可以用system("abc.exe -s=com1 &amp;");来让abc.exe后台运行。</span><br /><span class="f006">: 但在windows下，安装了activeperl，怎么来实现类似与上面的后台运行？谢了！！！</span><br /><br /><br /><br />--<br /><br />※ 来源:·水木社区 <a href="http://newsmth.net/" target="_blank"><font color="#002c99">http://newsmth.net</font></a>·[FROM: 159.226.43.*]<br /></div>
				<br />
				<div class="tconPager smaller left">[<a href="http://www.smth.org/bbscon.php?bid=226&amp;id=31037"><font color="#002c99">本篇全文</font></a>] [<a href="http://www.smth.org/bbspst.php?board=Perl&amp;reid=31037"><font color="#002c99">回复文章</font></a>] [本篇作者：<a href="http://www.smth.org/bbsqry.php?userid=cm3"><font color="#002c99">cm3</font></a>] [<a href="http://www.smth.org/bbspstmail.php?board=Perl&amp;id=31037"><font color="#002c99">回信给作者</font></a>] [<a href="http://www.smth.org/bbsdoc.php?board=Perl"><font color="#002c99">进入讨论区</font></a>] [<a href="http://www.smth.org/bbstcon.php?board=Perl&amp;gid=31029#top"><font color="#002c99">返回顶部</font></a>] 
<div class="tnum">3</div></div>
				<div class="article" id="art31037">发信人: cm3 (cm3), 信区: Perl<br />标  题: Re: windows 下的system命令的后台运行求助<br />发信站: 水木社区 (Thu Aug 10 16:32:52 2006), 站内<br /><br />可以！非常非常感谢！！！<br />【 在 qcpassed (xiaoqiao) 的大作中提到: 】<br /><span class="f006">: 看看system("start abc.exe -s=com1 ");行么</span><br /></div>
		</div>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/62878.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-10 23:04 <a href="http://www.blogjava.net/weidagang2046/articles/62878.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Perl处理Unix命令输出</title><link>http://www.blogjava.net/weidagang2046/articles/62235.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Mon, 07 Aug 2006 13:34:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/62235.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/62235.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/62235.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/62235.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/62235.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #008000">#</span>
				<span style="COLOR: #008000">!/usr/bin/perl -w</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">open</span>
				<span style="COLOR: #000000">( FILE</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">ls -l |</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000"> );<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000"> ( </span>
				<span style="COLOR: #800080">$line</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">FILE</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> )<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">chop</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$line</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$line</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">close</span>
				<span style="COLOR: #000000">(FILE);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
		</div>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/62235.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-07 21:34 <a href="http://www.blogjava.net/weidagang2046/articles/62235.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Perl文件及目录操作</title><link>http://www.blogjava.net/weidagang2046/articles/61995.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Sat, 05 Aug 2006 14:09:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/61995.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/61995.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/61995.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/61995.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/61995.html</trackback:ping><description><![CDATA[
		<font face="Verdana" color="#000000" size="2">大多数程序都不是孤立的,它们与它们的环境相互作用。很多的程序也需要通过文件操作实现数据的存贮和交换。 文件句柄(file handle)是Perl程序中为程序和外部世界提供I/O连接的名称。建议全部使用大写字母以示与变量等的区别。特别地，也可以将STDIN/STDOUT/STDERR也认为 是Perl的文件句柄，分别代表标准输入/标准输出/标准错误输出。  <br /><br />打开及关闭文件  <br /><br />　　Perl的文件操作与C语言极为相似。如：  <br /><br />open(FILENAME,"abc.txt");  <br /><br />　　该调用为读文件打开，若为写文件而打开，需在文件名前加上大于号：  <br /><br />open(FILENAME,"&gt;abc.txt");  <br /><br />　　若要追加至文件尾，可在文件名前加上两个大于号：  <br /><br />open(FILENAME,"&gt;&gt;abc.txt");  <br /><br />　　以上三种open()格式在成功时返回真，失败时返回假。但程序中通常没有提示，出错时往往会被人们忽略。 通常当需要给出出错提示时，可加入die()函数。例：  <br /><br />open(OUTFILE,"&gt;/tmp/outfile")||  <br />die "出错，不能建立/tmp/outfile\n";  <br /><br />　　当只有open失败时，才会执行die给出出错提示。  <br /><br />　　对文件句柄的操作完成后，可以用close操作符关闭文件。如：  <br /><br />close(OUTFILE);  <br /><br />-x 文件测试  <br /><br />　　Perl的文件操作也可以先测试文件是否存在，是否可读写等。如：  <br /><br />$x="abc.txt";  <br />if(-e $x) { #abc.txt是否存在？  <br /># 存在操作  <br />} else {  <br />printf "文件不存在。\n";  <br />}  <br /><br />-e操作符测试文件或目录是否存在。  <br /><br />　　以下为文件测试清单：  <br /><br /><br /><br />文件测试 测试操作符提供的信息  <br />-r 文件或目录可读  <br />-w 文件或目录可写  <br />-x 文件或目录执行  <br />-o 文件或目录归用户所有  <br />-R 文件或目录对真正用户可读  <br />-W 文件或目录对真正用户可写  <br />-X 文件或目录对真正用户执行  <br />-O 文件或目录归真正用户所有  <br />-e 文件或目录存在  <br />-z 文件存在且大小为0  <br />-s 文件或目录存在且不为0(返回字节数)  <br />-f 文件为普通文件  <br />-d 文件为目录  <br />-l 文件为符号链接  <br />-p 文件为命名管道(FIFO)  <br />-S 文件为一个套口(socket)  <br />-b 文件为块特殊文件  <br />-c 文件为字符特殊文件  <br />-t 打开tty控制台的文件句柄  <br />-u 文件或目录是设置用户ID号  <br />-g 文件或目录是设置用户组ID号  <br />-k 文件或目录的sticky位置位  <br />-T 文件是文本文件  <br />-B 文件是二进制文件  <br />-M 以天为单位的存在时间  <br />-A 以天为单位访问时间  <br />-C 以天为单位同代码更改时间  <br /><br /><br />删除文件  <br /><br />　　Perl的unlink()操作符可实现删除文件。如：  <br /><br />unlink("abc.txt"); #删除abc.txt  <br /><br />文件重命名  <br /><br />　　Perl的rename()操作符可实现文件重命名。如：  <br /><br />rename("abc","zmd")||die "出错,不能更名";  <br /><br />　　此时将abc更名为zmd，成功返回真，否则给出出错提示。  <br /><br />目录操作  <br /><br />　　Perl中处理目录非常类似于处理文件。  <br /><br />　　打开目录句柄：  <br /><br />opendir(ETC,"/etc")||die "出错,不能打开目录";  <br /><br />　　关闭目录句柄：  <br /><br />closedir(ETC);  <br /><br />　　创建目录：  <br /><br />mkdir("zmd",0777)||die "不能创建zmd目录";  <br /><br />　　0777为内部权限格式。  <br /><br />　　删除目录：  <br /><br />rmdir("zmd")||die "不能删除zmd目录"。</font>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/61995.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-08-05 22:09 <a href="http://www.blogjava.net/weidagang2046/articles/61995.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>去掉特殊字符</title><link>http://www.blogjava.net/weidagang2046/articles/47572.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Tue, 23 May 2006 01:09:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/47572.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/47572.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/47572.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/47572.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/47572.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">perl </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">pi</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">*.orig</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">e </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">s/[\cM\c@]//g</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000"> file<br /></span>
		</div>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/47572.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-05-23 09:09 <a href="http://www.blogjava.net/weidagang2046/articles/47572.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>30 个子进程来并行下载不同的链接</title><link>http://www.blogjava.net/weidagang2046/articles/47327.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Sun, 21 May 2006 12:37:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/47327.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/47327.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/47327.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/47327.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/47327.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #0000ff">use</span>
				<span style="COLOR: #000000"> LWP</span>
				<span style="COLOR: #000000">::</span>
				<span style="COLOR: #000000">Simple;<br />  </span>
				<span style="COLOR: #0000ff">use</span>
				<span style="COLOR: #000000"> Parallel</span>
				<span style="COLOR: #000000">::</span>
				<span style="COLOR: #000000">ForkManager;<br /><br />  </span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span style="COLOR: #000000">
						<br />
						<br />  </span>
				<span style="COLOR: #800080">@links</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">( <br />    [</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">http://www.foo.bar/rulez.data</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">rulez_data.txt</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> <br />    [</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">http://new.host/more_data.doc</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">more_data.doc</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">
						<br />    </span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span style="COLOR: #000000">
						<br />  );<br /><br />  </span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span style="COLOR: #000000">
						<br />
						<br />  </span>
				<span style="COLOR: #008000">#</span>
				<span style="COLOR: #008000"> 同时使用 30 个进程</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$pm</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> new Parallel</span>
				<span style="COLOR: #000000">::</span>
				<span style="COLOR: #000000">ForkManager(</span>
				<span style="COLOR: #800000">30</span>
				<span style="COLOR: #000000">); <br /><br />  </span>
				<span style="COLOR: #0000ff">foreach</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$linkarray</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">@links</span>
				<span style="COLOR: #000000">) {<br />    </span>
				<span style="COLOR: #800080">$pm</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">start and </span>
				<span style="COLOR: #0000ff">next</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #008000">#</span>
				<span style="COLOR: #008000"> 开始 fork</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">
						<br />    </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$link</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$fn</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> @</span>
				<span style="COLOR: #800080">$linkarray</span>
				<span style="COLOR: #000000">;<br />    </span>
				<span style="COLOR: #0000ff">warn</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">Cannot get $fn from $link</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000"> <br />      </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> getstore(</span>
				<span style="COLOR: #800080">$link</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$fn</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">!=</span>
				<span style="COLOR: #000000"> RC_OK;<br /><br />    </span>
				<span style="COLOR: #800080">$pm</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">finish; </span>
				<span style="COLOR: #008000">#</span>
				<span style="COLOR: #008000"> do the exit in the child process</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">  }<br />  </span>
				<span style="COLOR: #800080">$pm</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">wait_all_children;</span>
		</div>
		<p>首先通过 new 来初始化一个 ForkManager 对象，同时必须标明最大进程数。如果使用 0 的话就可以避免 fork 来达到调试程序的作用。</p>
		<p>然后使用 $pm-&gt;start 来开始 fork。 $pm 在子进程时返回 0 ,父进程时返回子进程的进程号（具体请参阅 Perl 的 fork 文档）。“and next” 用来跳过父进程。注意：如果 fork 失败的话， $pm-&gt;start 就提示错误，程序结束。</p>
		<p>$pm-&gt;finish 结束子程序（假设我们一开始使用了 start 来 fork）</p>
		<p>注意：在子进程中不能使用 $pm-&gt;start。 如果你想在子进程中使用另外一组子进程，你必须再初始化一个 Parallel::ForkManager 对象。<br /><br />from: <a href="http://www.perlchina.org/archive/archive.php?action=archive&amp;page=44">http://www.perlchina.org/archive/archive.php?action=archive&amp;page=44</a></p>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/47327.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-05-21 20:37 <a href="http://www.blogjava.net/weidagang2046/articles/47327.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ping子网内各主机的并发实现</title><link>http://www.blogjava.net/weidagang2046/articles/47326.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Sun, 21 May 2006 12:29:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/47326.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/47326.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/47326.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/47326.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/47326.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">sub</span>
				<span style="COLOR: #000000"> ping_a_host {<br />      </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$host</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">shift</span>
				<span style="COLOR: #000000">;<br />      `ping </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">i </span>
				<span style="COLOR: #800000">1</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">c </span>
				<span style="COLOR: #800000">1</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$host</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">2</span>
				<span style="COLOR: #000000">&gt;/</span>
				<span style="COLOR: #000000">dev</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">null` </span>
				<span style="COLOR: #000000">=~</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #800000">0</span>
				<span style="COLOR: #000000"> packets rec</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">0</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">:</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">1</span>
				<span style="COLOR: #000000">;<br />    }<br /><br />    </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">%pid_to_host</span>
				<span style="COLOR: #000000">;<br />    </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">%host_result</span>
				<span style="COLOR: #000000">;<br /><br />    </span>
				<span style="COLOR: #0000ff">sub</span>
				<span style="COLOR: #000000"> wait_for_a_kid {<br />      </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$pid</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">wait</span>
				<span style="COLOR: #000000">;<br />      </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">0</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$pid</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">0</span>
				<span style="COLOR: #000000">;<br />      </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$host</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">delete</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$pid_to_host</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #800080">$pid</span>
				<span style="COLOR: #000000">}<br />        or </span>
				<span style="COLOR: #0000ff">warn</span>
				<span style="COLOR: #000000">(</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">Why did I see $pid ($?)\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">next</span>
				<span style="COLOR: #000000">;<br />      </span>
				<span style="COLOR: #0000ff">warn</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">reaping $pid for $host\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />      </span>
				<span style="COLOR: #800080">$host_result</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #800080">$host</span>
				<span style="COLOR: #000000">} </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> $</span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">0</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">:</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">1</span>
				<span style="COLOR: #000000">;<br />      </span>
				<span style="COLOR: #800000">1</span>
				<span style="COLOR: #000000">;<br />    }<br /><br />    </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">@hosts</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">map</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">10.0.1.$_</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">001</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">..</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">254</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><br />    </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">@hosts</span>
				<span style="COLOR: #000000">) {<br />      wait_for_a_kid() </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">keys</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">%pid_to_host</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">10</span>
				<span style="COLOR: #000000">;<br />      </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$pid</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">fork</span>
				<span style="COLOR: #000000">) {<br />        </span>
				<span style="COLOR: #008000">#</span>
				<span style="COLOR: #008000"># parent does<img src="http://www.blogjava.net/images/dot.gif" /></span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">        </span>
				<span style="COLOR: #800080">$pid_to_host</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #800080">$pid</span>
				<span style="COLOR: #000000">} </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$_</span>
				<span style="COLOR: #000000">;<br />        </span>
				<span style="COLOR: #0000ff">warn</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">$pid is processing $_\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />      } </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> { </span>
				<span style="COLOR: #008000">#</span>
				<span style="COLOR: #008000"> child does<br />        ## child does<img src="http://www.blogjava.net/images/dot.gif" /></span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">        </span>
				<span style="COLOR: #0000ff">exit</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">!</span>
				<span style="COLOR: #000000">ping_a_host(</span>
				<span style="COLOR: #800080">$_</span>
				<span style="COLOR: #000000">);<br />      }<br />    }<br /><br />    </span>
				<span style="COLOR: #008000">#</span>
				<span style="COLOR: #008000"># final reap:</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #800000">1</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000"> wait_for_a_kid();<br /><br />    </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #0000ff">sort</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">keys</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">%host_result</span>
				<span style="COLOR: #000000">) {<br />      </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">$_ is </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$host_result</span>
				<span style="COLOR: #000000">{</span>
				<span style="COLOR: #800080">$_</span>
				<span style="COLOR: #000000">} </span>
				<span style="COLOR: #000000">?</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">good</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">:</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">bad</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br />    }<br /></span>
		</div>
		<br />from: <a href="http://www.perlchina.org/archive/archive.php?action=archive&amp;page=44">http://www.perlchina.org/archive/archive.php?action=archive&amp;page=44</a><img src ="http://www.blogjava.net/weidagang2046/aggbug/47326.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-05-21 20:29 <a href="http://www.blogjava.net/weidagang2046/articles/47326.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Perl 模块多平台下安装方法</title><link>http://www.blogjava.net/weidagang2046/articles/46454.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Tue, 16 May 2006 10:01:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/46454.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/46454.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/46454.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/46454.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/46454.html</trackback:ping><description><![CDATA[Perl 到了第五版增加了模块的概念，用来提供面向对象编程的能力。这是 Perl 语言发展史上的一个里程碑。此后，广大自由软件爱好者开发了大量功能强大、构思精巧的 Perl 模块，极大地扩展了 Perl 语言的功能。CPAN（Comprehensive Perl Archive Network）是 Perl 模块最大的集散地，包含了现今公布的几乎所有的 perl 模块。 
<p></p><p><strong>几个主要的 CPAN 站点有：</strong></p><ul><li>国内：<br />最新更新请查阅 <a href="http://cpan.org/SITES.html">http://cpan.org/SITES.html#Asia</a></li></ul><ul><li><a href="ftp://mirrors.hknet.com/CPAN">ftp://mirrors.hknet.com/CPAN</a> 模块镜像 
</li><li><a href="http://mirrors.dayouit.com/CPAN/">http://mirrors.dayouit.com/CPAN/</a> 网页镜像 
</li><li><a href="http://cpan.linuxforum.net/">http://cpan.linuxforum.net/</a> 网页镜像 </li></ul><ul><li>国外： </li></ul><ul><li><a href="http://www.cpan.org/">http://www.cpan.org/</a></li></ul><p><strong>安装方法</strong></p><p>我在这里介绍一下各种平台下 perl 模块的安装方法。以安装DBI模块为例。</p><p><strong>Linux/Unix下的安装方法：</strong></p><p>Linux/Unix 下安装 Perl 模块有两种方法：手工安装和自动安装。第一种方法是从 <span class="caps">CPAN </span>上下载您需要的模块，手工编译、安装。第二种方法是使用 <span class="caps">CPAN </span>模块自动完成下载、编译、安装的全过程。</p><ul><li>手工安装的步骤： </li></ul><ul><li>从 CPAN 下载了 <span class="caps">DBI </span>模块 1.13 版的压缩文件 <span class="caps">DBI</span>-1.13.tar.gz，假设放在 /usr/local/src/ 下。 </li></ul><ul><li><code>cd /usr/local/src</code></li></ul><ul><li>解压缩这个文件,这时会新建一个DBI-1.13的目录。<br /><br /><code>tar xvzf DBI-1.13.tar.gz</code></li></ul><ul><li>换到解压后的目录： <code>cd DBI-1.13</code></li></ul><ul><li>生成 makefile：<code>perl Makefile.PL</code></li></ul><ul><li>生成模块：<code>make</code></li></ul><ul><li>测试模块（这步可有可无）： <code>make test</code><br />如果测试结果报告“all test ok”，您就可以放心地安装编译好的模块了。 </li></ul><ul><li>安装模块前，先要确保您对 perl5 安装目录有可写权限（通常以 su 命令获得），执行：<br /><br /><code>make install</code></li></ul><ul><li>现在，试试 DBI 模块吧。如果下面的命令没有给出任何输出，那就没问题。<br /><code>$&gt;perl -MDBI -e1</code><br /><br />上述步骤适合于 Linux/Unix 下绝大多数的 Perl 模块。可能还有少数模块的安装方法略有差别，所以最好先看看安装目录里的 README 或 INSTALL。 </li></ul><ul><li>使用 CPAN 模块自动安装：<br />安装前需要先联上网，并且您需要取得root权限。 </li></ul><ul><li><code>perl -MCPAN -e shell</code><br /><br />初次运行CPAN时需要做一些设置，如果您的机器是直接与因特网相联（拨号上网、专线，etc.），那么一路回车就行了，只需要在最后一步选一个离您最近的 <span class="caps">CPAN </span>镜像站点。例如我选的是位于国内的<a href="ftp://mirrors.hknet.com/CPAN">ftp://mirrors.hknet.com/CPAN</a> 。否则，如果您的机器位于防火墙之后，还需要设置ftp代理或http代理。下面是常用 ppm 命令。 </li></ul><ul><li>获得帮助<br /><code>cpan&gt;help</code></li></ul><ul><li>列出CPAN上所有模块的列表<br /><code>cpan&gt;m</code></li></ul><ul><li>安装模块，自动完成DBI模块从下载到安装的全过程。<br /><code>cpan&gt;install DBI</code></li></ul><ul><li>退出<br /><code>cpan&gt;quit</code></li></ul><p><strong>Win32下的安装方法：</strong></p><p>在 Win32 下，建议使用 <span class="newWikiWord">Active State</span> 的 Perl for Win32，即<span class="newWikiWord">Active Perl。Active Perl</span> 的主页在：<br /><a href="http://www.activestate.com/">http://www.activestate.com/</a> 。<br />在 Win32 下，比较容易的是使用专门为 <span class="newWikiWord">Active Perl<a href="http://www.perlchina.org/show/ActivePerl">?</a></span> 定制的 Perl 模块。类似于 <span class="caps">CPAN </span>模块，<span class="newWikiWord">Active State也开发了一个自动安装工具叫做</span><span class="caps">PPM</span>（Perl Package Manager）。</p><ul><li>最通常的安装方法是： </li></ul><ul><li>首先联上网，在 dos 命令行下启动 ppm <br /><code>ppm</code></li></ul><ul><li>获得帮助<br /><code>PPM&gt;h</code></li></ul><ul><li>列出已安装的 <span class="caps">DBI </span>模块信息<br /><code>cpan&gt;query DBI</code></li></ul><ul><li>搜索 cpan 所有匹配 <span class="caps">DBI </span>的模块<br /><code>cpan&gt;search DBI</code></li></ul><ul><li>安装模块，自动完成 <span class="caps">DBI </span>模块从下载到安装的全过程。<br /><code>PPM&gt;install DBI</code></li></ul><ul><li>退出<br /><code>PPM&gt;q</code></li></ul><ul><li>如果您的机器位于防火墙之后，通过 http 代理上网，那么可以使用下面的方法。 </li></ul><ul><li>设定环境变量 <span class="caps">HTTP</span>_proxy <br /><code>C: \ &gt; set HTTP_proxy=http://proxy:8080</code><br />如果你的代理需要用户名和密码，你还要设定环境变量: <span class="caps">HTTP</span>_proxy_user 和 <span class="caps">HTTP</span>_proxy_pass </li></ul><ul><li>安装 activeperl 不包括的模块<br />如果 ppm 没有某个 <span class="caps">CPAN </span>的模块，只要这个模块不需要编译（没有使用 C 等）那你可以把这个模块从 <span class="caps">CPAN </span>下载，解压然后放到你的 activeperl 的库路径里， <code>perl -e "print join ' ' @INC"</code> 显示出 perl 的库路径。 </li></ul><ul><li>activeperl 里不包括所有的 <span class="caps">CPAN </span>模块，其他地方可能提供这些模块的下载， 
</li><li>比如在 activeperl 5.8 的 <span class="caps">GD </span>模块安装请使用如下命令：<br /><code>&gt;ppm install http://theoryx5.uwinnipeg.ca/ppms/GD.ppd</code></li><li>activeperl 5.6 的 <span class="caps">GD </span>模块安装请使用如下命令：<br /><code>&gt;ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/GD.ppd</code></li><li>其他 activeperl 模块下载地址请参照 <a href="http://wiki.perlchina.org/main/show/Perl%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97">Perl学习指南</a> 。 </li></ul><p>以上较为详细地描述了各种平台下 Perl 模块的安装方法。希望能够帮助国内 Perl 爱好者们通过使用现有大量优秀的 Perl 模块，避免重复劳动，提高效率，更好发挥 Perl 语言的强大威力。<br /><br />from: <a href="http://www.perlchina.org/archive/archive.php?action=archive&amp;page=51">http://www.perlchina.org/archive/archive.php?action=archive&amp;page=51</a></p><img src ="http://www.blogjava.net/weidagang2046/aggbug/46454.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-05-16 18:01 <a href="http://www.blogjava.net/weidagang2046/articles/46454.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>How can I use Perl interactively?</title><link>http://www.blogjava.net/weidagang2046/articles/45122.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Mon, 08 May 2006 16:35:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/45122.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/45122.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/45122.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/45122.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/45122.html</trackback:ping><description><![CDATA[The easiest way to do this is to run Perl under its debugger. If you have no program to debug, you can invoke the debugger on an `empty' program like this: <pre>perl -de 0

</pre>(The more positive hackers prefer <tt>perl -de 1</tt>. :-) 
<p>Now you can type in any legal Perl code, and it will be immediately evaluated. You can also examine the symbol table, get stack backtraces, check variable values, and if you want to, set breakpoints and do the other things you can do in a symbolic debugger. <br /><br />from: <a href="http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q3.1.html">http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q3.1.html</a></p><img src ="http://www.blogjava.net/weidagang2046/aggbug/45122.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-05-09 00:35 <a href="http://www.blogjava.net/weidagang2046/articles/45122.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ref函数判断变量是何种类型的引用</title><link>http://www.blogjava.net/weidagang2046/articles/45119.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Mon, 08 May 2006 16:16:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/45119.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/45119.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/45119.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/45119.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/45119.html</trackback:ping><description><![CDATA[
		<p>    ref EXPR<br />    ref     Returns a non-empty string if EXPR is a reference, the empty<br />            string otherwise. If EXPR is not specified, $_ will be used. The<br />            value returned depends on the type of thing the reference is a<br />            reference to. Builtin types include:</p>
		<p>                SCALAR<br />                ARRAY<br />                HASH<br />                CODE<br />                REF<br />                GLOB<br />                LVALUE</p>
		<p>            If the referenced object has been blessed into a package, then<br />            that package name is returned instead. You can think of "ref" as<br />            a "typeof" operator.</p>
		<p>                if (ref($r) eq "HASH") {<br />                    print "r is a reference to a hash.\n";<br />                }<br />                unless (ref($r)) {<br />                    print "r is not a reference at all.\n";<br />                }<br />                if (UNIVERSAL::isa($r, "HASH")) {  # for subclassing<br />                    print "r is a reference to something that isa hash.\n";<br />                }</p>
		<p>            See also perlref.</p>
		<p> </p>
<img src ="http://www.blogjava.net/weidagang2046/aggbug/45119.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weidagang2046/" target="_blank">weidagang2046</a> 2006-05-09 00:16 <a href="http://www.blogjava.net/weidagang2046/articles/45119.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>删除某目录下最后修改日期大于X天的文件</title><link>http://www.blogjava.net/weidagang2046/articles/44257.html</link><dc:creator>weidagang2046</dc:creator><author>weidagang2046</author><pubDate>Sun, 30 Apr 2006 16:47:00 GMT</pubDate><guid>http://www.blogjava.net/weidagang2046/articles/44257.html</guid><wfw:comment>http://www.blogjava.net/weidagang2046/comments/44257.html</wfw:comment><comments>http://www.blogjava.net/weidagang2046/articles/44257.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weidagang2046/comments/commentRss/44257.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weidagang2046/services/trackbacks/44257.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">use</span>
				<span style="COLOR: #000000"> strict;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">use</span>
				<span style="COLOR: #000000"> warnings;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">@ARGV</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">0</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">||</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">die</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">Usage: perl file_checker.pl [dir]\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">opendir</span>
				<span style="COLOR: #000000">(DIR</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$ARGV</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800000">0</span>
				<span style="COLOR: #000000">]) </span>
				<span style="COLOR: #000000">||</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">die</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">Can't open directory: $!\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">@file_list</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">readdir</span>
				<span style="COLOR: #000000">(DIR);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">foreach</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">my</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">@file_list</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">$ARGV[0]/$file</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">f </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    {<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">M </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800000">100</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        {<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span>
				<span style="COLOR: #0000ff">print</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$file</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">\n</span>
				<span style="FONT-WEIGHT: bold; COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<