<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lauct&#039;s BLOG &#187; Programming</title>
	<atom:link href="http://blog.lauct.org/archives/tag/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.lauct.org</link>
	<description>噢！醒來吧，沉睡者。</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:13:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://blog.lauct.org/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>[Java] 各種型別(Type)的預設初值(Initial Value)</title>
		<link>http://blog.lauct.org/archives/1871</link>
		<comments>http://blog.lauct.org/archives/1871#comments</comments>
		<pubDate>Fri, 13 May 2011 03:59:29 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[閱讀筆記]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1871</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
Type Initial Value boolean false char &#8216;\u0000&#8242; byte, short, int, long 0 float, double +0.0 object reference null Related posts:[Java] 把 OutputStream 的內容存到檔案 [Python] 學習參考資料: 如何像電腦科學家一樣思考、電腦做什麼事 [Java] 一般 Java 程式碼的結構長這樣


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1856' rel='bookmark' title='Permanent Link: [Java] 把 OutputStream 的內容存到檔案'>[Java] 把 OutputStream 的內容存到檔案</a></li>
<li><a href='http://blog.lauct.org/archives/1458' rel='bookmark' title='Permanent Link: [Python] 學習參考資料: 如何像電腦科學家一樣思考、電腦做什麼事'>[Python] 學習參考資料: 如何像電腦科學家一樣思考、電腦做什麼事</a></li>
<li><a href='http://blog.lauct.org/archives/1539' rel='bookmark' title='Permanent Link: [Java] 一般 Java 程式碼的結構長這樣'>[Java] 一般 Java 程式碼的結構長這樣</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<table style="text-align: left;" border="2" cellspacing="10" cellpadding="10">
<tbody>
<tr>
<td valign="top"><strong>Type</strong></td>
<td valign="top"><strong>Initial Value</strong></td>
</tr>
<tr>
<td valign="top">boolean</td>
<td valign="top">false</td>
</tr>
<tr>
<td valign="top">char</td>
<td valign="top">&#8216;\u0000&#8242;</td>
</tr>
<tr>
<td valign="top">byte, short, int, long</td>
<td valign="top">0</td>
</tr>
<tr>
<td valign="top">float, double</td>
<td valign="top">+0.0</td>
</tr>
<tr>
<td valign="top">object reference</td>
<td valign="top">null</td>
</tr>
</tbody>
</table>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1856' rel='bookmark' title='Permanent Link: [Java] 把 OutputStream 的內容存到檔案'>[Java] 把 OutputStream 的內容存到檔案</a></li>
<li><a href='http://blog.lauct.org/archives/1458' rel='bookmark' title='Permanent Link: [Python] 學習參考資料: 如何像電腦科學家一樣思考、電腦做什麼事'>[Python] 學習參考資料: 如何像電腦科學家一樣思考、電腦做什麼事</a></li>
<li><a href='http://blog.lauct.org/archives/1539' rel='bookmark' title='Permanent Link: [Java] 一般 Java 程式碼的結構長這樣'>[Java] 一般 Java 程式碼的結構長這樣</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1871/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Git] 切換至某tag的branch</title>
		<link>http://blog.lauct.org/archives/1807</link>
		<comments>http://blog.lauct.org/archives/1807#comments</comments>
		<pubDate>Thu, 27 Jan 2011 10:43:52 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1807</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
git clone http://git.example.com/git/example.git my_abc git clone will give you the whole repository. git tag -l list tags git checkout -b &#60;new_branch_name&#62; &#60;tag_name&#62; create a new branch from git checkout &#60;branch_name&#62; Switch to a new branch &#8216;branch_name&#8217; Related posts:[URL] 用 Mac OS X Tiger (10.4) 製作 CD/DVD ISO 映像檔 [iPhoneDev] 把 Localizable.strings 由 Apple binary property [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1493' rel='bookmark' title='Permanent Link: [URL] 用 Mac OS X Tiger (10.4) 製作 CD/DVD ISO 映像檔'>[URL] 用 Mac OS X Tiger (10.4) 製作 CD/DVD ISO 映像檔</a></li>
<li><a href='http://blog.lauct.org/archives/1482' rel='bookmark' title='Permanent Link: [iPhoneDev] 把 Localizable.strings 由 Apple binary property list 轉成 XML'>[iPhoneDev] 把 Localizable.strings 由 Apple binary property list 轉成 XML</a></li>
<li><a href='http://blog.lauct.org/archives/201' rel='bookmark' title='Permanent Link: 來逛livedoor PICS'>來逛livedoor PICS</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git clone http:<span style="color: #000000; font-weight: bold;">//</span>git.example.com<span style="color: #000000; font-weight: bold;">/</span>git<span style="color: #000000; font-weight: bold;">/</span>example.git my_abc</pre></div></div>

<p>git clone will give you the whole repository.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git tag <span style="color: #660033;">-l</span></pre></div></div>

<p>list tags</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git checkout <span style="color: #660033;">-b</span> <span style="color: #000000; font-weight: bold;">&lt;</span>new_branch_name<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>tag_name<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>create a new branch from <tag_name></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git checkout <span style="color: #000000; font-weight: bold;">&lt;</span>branch_name<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Switch to a new branch &#8216;branch_name&#8217;</p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1493' rel='bookmark' title='Permanent Link: [URL] 用 Mac OS X Tiger (10.4) 製作 CD/DVD ISO 映像檔'>[URL] 用 Mac OS X Tiger (10.4) 製作 CD/DVD ISO 映像檔</a></li>
<li><a href='http://blog.lauct.org/archives/1482' rel='bookmark' title='Permanent Link: [iPhoneDev] 把 Localizable.strings 由 Apple binary property list 轉成 XML'>[iPhoneDev] 把 Localizable.strings 由 Apple binary property list 轉成 XML</a></li>
<li><a href='http://blog.lauct.org/archives/201' rel='bookmark' title='Permanent Link: 來逛livedoor PICS'>來逛livedoor PICS</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1807/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[URL][Doc] Advanced Linux Programming 中文翻譯計畫</title>
		<link>http://blog.lauct.org/archives/1792</link>
		<comments>http://blog.lauct.org/archives/1792#comments</comments>
		<pubDate>Wed, 05 Jan 2011 15:31:31 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[Unix-like]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1792</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
Advanced Linux Programming 中文翻譯 Linux 系统高级编程 Related posts:找會 Linux 的人 [Linux][URL] Arch Linux 準備 Linux 認證的一些注意事項與學習順序參考


Related posts:<ol><li><a href='http://blog.lauct.org/archives/857' rel='bookmark' title='Permanent Link: 找會 Linux 的人'>找會 Linux 的人</a></li>
<li><a href='http://blog.lauct.org/archives/1476' rel='bookmark' title='Permanent Link: [Linux][URL] Arch Linux'>[Linux][URL] Arch Linux</a></li>
<li><a href='http://blog.lauct.org/archives/532' rel='bookmark' title='Permanent Link: 準備 Linux 認證的一些注意事項與學習順序參考'>準備 Linux 認證的一些注意事項與學習順序參考</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p><a href="http://www.advancedlinuxprogramming.com/">Advanced Linux Programming</a></p>
<p>中文翻譯<br />
<a href="http://sourceforge.net/apps/trac/elpi/wiki/ALP">Linux 系统高级编程</a></p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/857' rel='bookmark' title='Permanent Link: 找會 Linux 的人'>找會 Linux 的人</a></li>
<li><a href='http://blog.lauct.org/archives/1476' rel='bookmark' title='Permanent Link: [Linux][URL] Arch Linux'>[Linux][URL] Arch Linux</a></li>
<li><a href='http://blog.lauct.org/archives/532' rel='bookmark' title='Permanent Link: 準備 Linux 認證的一些注意事項與學習順序參考'>準備 Linux 認證的一些注意事項與學習順序參考</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1792/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Perl] 反轉數字陣列印出並加入分隔</title>
		<link>http://blog.lauct.org/archives/1779</link>
		<comments>http://blog.lauct.org/archives/1779#comments</comments>
		<pubDate>Sun, 02 Jan 2011 18:13:40 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[Unix-like]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1779</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
1 2 3 4 5 6 7 8 9 10 11 12 13 14 #!/bin/perl -w &#160; @isbn = &#40; &#34;9789861058092&#34;, &#34;9789861053134&#34;, &#34;9789861050355&#34;, &#34;9789861044965&#34;, &#34;9789861039855&#34;, &#34;9789861036182&#34;, &#34;9789861031958&#34;, &#34;9789861027364&#34;, &#34;9789861022499&#34;&#41;; @s = reverse @isbn; print join &#34;\n&#34;,@s,&#34;\n&#34;; result: 9789861022499 9789861027364 9789861031958 9789861036182 9789861039855 9789861044965 9789861050355 9789861053134 9789861058092 Related posts:[Perl] 私人工具箱：flickr2bps [Perl] 常見特殊變數 [Perl][轉錄] 實例說明 Perl 特殊變數


Related posts:<ol><li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
<li><a href='http://blog.lauct.org/archives/1438' rel='bookmark' title='Permanent Link: [Perl] 常見特殊變數'>[Perl] 常見特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/perl -w</span>
&nbsp;
<span style="color: #0000ff;">@isbn</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> 
<span style="color: #ff0000;">&quot;9789861058092&quot;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;9789861053134&quot;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;9789861050355&quot;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;9789861044965&quot;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;9789861039855&quot;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;9789861036182&quot;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;9789861031958&quot;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;9789861027364&quot;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;9789861022499&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">@s</span> <span style="color: #339933;">=</span> <span style="color: #000066;">reverse</span> <span style="color: #0000ff;">@isbn</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #000066;">join</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">@s</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>result:<br />
<code>9789861022499<br />
9789861027364<br />
9789861031958<br />
9789861036182<br />
9789861039855<br />
9789861044965<br />
9789861050355<br />
9789861053134<br />
9789861058092<br />
</code></p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
<li><a href='http://blog.lauct.org/archives/1438' rel='bookmark' title='Permanent Link: [Perl] 常見特殊變數'>[Perl] 常見特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1779/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Unix][Dev] Mac OS X 下使用 gtags 和 htags trace code</title>
		<link>http://blog.lauct.org/archives/1759</link>
		<comments>http://blog.lauct.org/archives/1759#comments</comments>
		<pubDate>Tue, 28 Dec 2010 04:25:58 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[Unix-like]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[StudyNote]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1759</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
利用MacPorts套件系統來安裝 http://www.macports.org/ sudo port install global 以 trace lftp 的 source code 為例 先抓下tarball wget -c http://ftp.yars.free.net/pub/source/lftp/lftp-4.1.1.tar.gz 解壓縮 tar zxvf lftp-4.1.1.tar.gz 切換進 source code 的 folder cd lftp-4.1.1 執行 htags 來產生 source code 的網頁 htags -g -Fnsa screenshot: 要有搜尋功能請到 HTML 目錄中底下的 cgi-bin 子目錄新增 .htaccess： Options +ExecCGI AddHandler cgi-script .cgi ps. 但我在 Mac OS X 10.6 [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1496' rel='bookmark' title='Permanent Link: [iPhone][Cydia]解決 wrong language code zh-hant 錯誤訊息'>[iPhone][Cydia]解決 wrong language code zh-hant 錯誤訊息</a></li>
<li><a href='http://blog.lauct.org/archives/816' rel='bookmark' title='Permanent Link: Command-line 最先進的 FTP client：lftp'>Command-line 最先進的 FTP client：lftp</a></li>
<li><a href='http://blog.lauct.org/archives/1430' rel='bookmark' title='Permanent Link: [UNIX] pidof：取得執行中程序的pid'>[UNIX] pidof：取得執行中程序的pid</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p>利用MacPorts套件系統來安裝 http://www.macports.org/</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> global</pre></div></div>

<p>以 trace lftp 的 source code 為例</p>
<p>先抓下tarball</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-c</span> http:<span style="color: #000000; font-weight: bold;">//</span>ftp.yars.free.net<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">source</span><span style="color: #000000; font-weight: bold;">/</span>lftp<span style="color: #000000; font-weight: bold;">/</span>lftp-4.1.1.tar.gz</pre></div></div>

<p>解壓縮</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf lftp-4.1.1.tar.gz</pre></div></div>

<p>切換進 source code 的 folder</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> lftp-4.1.1</pre></div></div>

<p>執行 htags 來產生 source code 的網頁</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">htags <span style="color: #660033;">-g</span> <span style="color: #660033;">-Fnsa</span></pre></div></div>

<p><!-- pre lang="bash">htags -g -F -f</pre -->
<!-- pre lang="bash">htags &#8211;suggest</pre -->
<p>screenshot:<br />
<a href="http://blog.lauct.org/wp-content/uploads/2010/12/lftp-htags.png"><img src="http://blog.lauct.org/wp-content/uploads/2010/12/lftp-htags-300x211.png" alt="" title="lftp-htags" width="300" height="211" class="aligncenter size-medium wp-image-1760" /></a></p>
<p>要有搜尋功能請到 HTML 目錄中底下的 cgi-bin 子目錄新增 .htaccess：</p>

<div class="wp_syntax"><div class="code"><pre class="config" style="font-family:monospace;">Options +ExecCGI
AddHandler cgi-script .cgi</pre></div></div>

<p>ps. 但我在 Mac OS X 10.6 上找不出怎麼正確讓 CGI-BIN 啟用的方法，所以暫時無法搜尋滿可惜的，有沒有先進知道該怎麼作呢？</p>
<p>ref1: http://chunchaichang.blogspot.com/2010/05/gtags-trace-code.html<br />
ref2: http://williewu.blogspot.com/2007/02/gnu-global-souce-code-tag-system.html<br />
ref3: http://welkinchen.blogspot.com/2009/10/gnu-global.html</p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1496' rel='bookmark' title='Permanent Link: [iPhone][Cydia]解決 wrong language code zh-hant 錯誤訊息'>[iPhone][Cydia]解決 wrong language code zh-hant 錯誤訊息</a></li>
<li><a href='http://blog.lauct.org/archives/816' rel='bookmark' title='Permanent Link: Command-line 最先進的 FTP client：lftp'>Command-line 最先進的 FTP client：lftp</a></li>
<li><a href='http://blog.lauct.org/archives/1430' rel='bookmark' title='Permanent Link: [UNIX] pidof：取得執行中程序的pid'>[UNIX] pidof：取得執行中程序的pid</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1759/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Django] 安裝與開新專案步驟</title>
		<link>http://blog.lauct.org/archives/1468</link>
		<comments>http://blog.lauct.org/archives/1468#comments</comments>
		<pubDate>Wed, 11 Nov 2009 02:10:36 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[Web開發]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[閱讀筆記]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1468</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
安裝 tar zxvf Django-*.tar.gz cd Django-*. sudo python setup.py install 開一個新專案 ~/djcode$ django-admin.py startproject mysite ~/djcode$ ls -a mysite/ ./ ../ __init__.py manage.py settings.py urls.py __init__.py: 偽裝目錄成package manage.py: 一個cli的工具，讓妳可以用多種方式和Django專案互動 settings.py: Django專案的設定/組態 urls.py: 此Django專案的URL宣告 執行開發用Server ~/djcode/mysite$ python manage.py runserver Validating models... 0 errors found &#160; Django version 1.1.1, using settings 'mysite.settings' Development server is running at [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1470' rel='bookmark' title='Permanent Link: [Django] 調整時區和語系'>[Django] 調整時區和語系</a></li>
<li><a href='http://blog.lauct.org/archives/1464' rel='bookmark' title='Permanent Link: [Python] 在Python中使用中文'>[Python] 在Python中使用中文</a></li>
<li><a href='http://blog.lauct.org/archives/1472' rel='bookmark' title='Permanent Link: [MacPorts][Python] python_select：選擇 Python 版本+手動指定'>[MacPorts][Python] python_select：選擇 Python 版本+手動指定</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p><strong>安裝</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf Django-<span style="color: #000000; font-weight: bold;">*</span>.tar.gz</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> Django-<span style="color: #000000; font-weight: bold;">*</span>.</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p><strong>開一個新專案</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">~<span style="color: #000000; font-weight: bold;">/</span>djcode$ django-admin.py startproject mysite</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">~<span style="color: #000000; font-weight: bold;">/</span>djcode$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-a</span> mysite<span style="color: #000000; font-weight: bold;">/</span>
.<span style="color: #000000; font-weight: bold;">/</span>           ..<span style="color: #000000; font-weight: bold;">/</span>          __init__.py  manage.py    settings.py  urls.py</pre></div></div>

<blockquote>
<ul>__init__.py: 偽裝目錄成package</ul>
<ul>manage.py: 一個cli的工具，讓妳可以用多種方式和Django專案互動</ul>
<ul>settings.py: Django專案的設定/組態</ul>
<ul>urls.py: 此Django專案的URL宣告</ul>
</blockquote>
<p><strong>執行開發用Server</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">~<span style="color: #000000; font-weight: bold;">/</span>djcode<span style="color: #000000; font-weight: bold;">/</span>mysite$ python manage.py runserver
Validating models...
<span style="color: #000000;">0</span> errors found
&nbsp;
Django version 1.1.1, using settings <span style="color: #ff0000;">'mysite.settings'</span>
Development server is running at http:<span style="color: #000000; font-weight: bold;">//</span>127.0.0.1:<span style="color: #000000;">8000</span><span style="color: #000000; font-weight: bold;">/</span>
Quit the server with CONTROL-C.
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">10</span><span style="color: #000000; font-weight: bold;">/</span>Nov<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span> <span style="color: #000000;">19</span>:<span style="color: #000000;">55</span>:<span style="color: #000000;">59</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET / HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">2053</span></pre></div></div>

<div id="attachment_1469" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.lauct.org/wp-content/uploads/2009/11/dj-runserver.png"><img src="http://blog.lauct.org/wp-content/uploads/2009/11/dj-runserver-300x239.png" alt="It worked!" title="dj-runserver" width="300" height="239" class="size-medium wp-image-1469" /></a><p class="wp-caption-text">It worked!</p></div>
<blockquote><p><strong>改Port或IP</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python manage.py runserver <span style="color: #000000;">8080</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python manage.py runserver 0.0.0.0:<span style="color: #000000;">8080</span></pre></div></div>

</blockquote>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1470' rel='bookmark' title='Permanent Link: [Django] 調整時區和語系'>[Django] 調整時區和語系</a></li>
<li><a href='http://blog.lauct.org/archives/1464' rel='bookmark' title='Permanent Link: [Python] 在Python中使用中文'>[Python] 在Python中使用中文</a></li>
<li><a href='http://blog.lauct.org/archives/1472' rel='bookmark' title='Permanent Link: [MacPorts][Python] python_select：選擇 Python 版本+手動指定'>[MacPorts][Python] python_select：選擇 Python 版本+手動指定</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1468/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Python] 在Python中使用中文</title>
		<link>http://blog.lauct.org/archives/1464</link>
		<comments>http://blog.lauct.org/archives/1464#comments</comments>
		<pubDate>Thu, 05 Nov 2009 03:18:29 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[CJKV]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1464</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
tchinese.py #!/bin/python print &#34;Python是個酷玩意&#34; python tchinese.py SyntaxError: Non-ASCII character '\xe6' in file tchinese.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details 錯誤訊息中的連結到這篇文章：PEP 0263 &#8212; Defining Python Source Code Encodings 文中提到： To define a source code encoding, a magic comment must be placed into the source files either as first or second line [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1472' rel='bookmark' title='Permanent Link: [MacPorts][Python] python_select：選擇 Python 版本+手動指定'>[MacPorts][Python] python_select：選擇 Python 版本+手動指定</a></li>
<li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
<li><a href='http://blog.lauct.org/archives/1539' rel='bookmark' title='Permanent Link: [Java] 一般 Java 程式碼的結構長這樣'>[Java] 一般 Java 程式碼的結構長這樣</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p>tchinese.py</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/bin/python</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Python是個酷玩意&quot;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python tchinese.py
SyntaxError: Non-ASCII character <span style="color: #ff0000;">'\xe6'</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #c20cb9; font-weight: bold;">file</span> tchinese.py on line <span style="color: #000000;">2</span>, but no encoding declared; see http:<span style="color: #000000; font-weight: bold;">//</span>www.python.org<span style="color: #000000; font-weight: bold;">/</span>peps<span style="color: #000000; font-weight: bold;">/</span>pep-0263.html <span style="color: #000000; font-weight: bold;">for</span> details</pre></div></div>

<p>錯誤訊息中的連結到這篇文章：<a href="http://www.python.org/dev/peps/pep-0263/">PEP 0263 &#8212; Defining Python Source Code Encodings</a><br />
文中提到：</p>
<blockquote><p>To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file, such as:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># coding=&lt;encoding name&gt;</span></pre></div></div>

<p>    or (using formats recognized by popular editors)</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
<span style="color: #808080; font-style: italic;"># -*- coding: &lt;encoding name&gt; -*-</span></pre></div></div>

<p>    or</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
<span style="color: #808080; font-style: italic;"># vim: set fileencoding=&lt;encoding name&gt; :</span></pre></div></div>

</blockquote>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/bin/python</span>
<span style="color: #808080; font-style: italic;"># -*- coding: utf-8 -*-</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Python是個酷玩意&quot;</span></pre></div></div>

<p>Result:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Python是個酷玩意</pre></div></div>



<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1472' rel='bookmark' title='Permanent Link: [MacPorts][Python] python_select：選擇 Python 版本+手動指定'>[MacPorts][Python] python_select：選擇 Python 版本+手動指定</a></li>
<li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
<li><a href='http://blog.lauct.org/archives/1539' rel='bookmark' title='Permanent Link: [Java] 一般 Java 程式碼的結構長這樣'>[Java] 一般 Java 程式碼的結構長這樣</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1464/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Python] 學習參考資料: 如何像電腦科學家一樣思考、電腦做什麼事</title>
		<link>http://blog.lauct.org/archives/1458</link>
		<comments>http://blog.lauct.org/archives/1458#comments</comments>
		<pubDate>Mon, 02 Nov 2009 11:52:04 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[Docs]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1458</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
如何像電腦科學家一樣思考How to Think Like a Computer Scientist (中譯版) 原文 這是一本不錯的 Python 工具書，適合 Python 初學者閱讀的入門書 中譯版 如何像電腦科學家一樣思考 如何像電腦科學家一樣思考 &#124; 1.程式之道 如何像電腦科學家一樣思考 &#124; 2. 變數、表達式及陳述 如何像電腦科學家一樣思考 &#124; 3. 函數 如何像電腦科學家一樣思考 &#124; 4. 條件式 如何像電腦科學家一樣思考 &#124; 5. 多效函數 如何像電腦科學家一樣思考 &#124; 6. 重複 如何像電腦科學家一樣思考 &#124; 7. 字串 如何像電腦科學家一樣思考 &#124; 8. 案例研究： Catch 如何像電腦科學家一樣思考 &#124; 9. Tuple 如何像電腦科學家一樣思考 &#124;10. 模組和檔案 如何像電腦科學家一樣思考 [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1472' rel='bookmark' title='Permanent Link: [MacPorts][Python] python_select：選擇 Python 版本+手動指定'>[MacPorts][Python] python_select：選擇 Python 版本+手動指定</a></li>
<li><a href='http://blog.lauct.org/archives/1464' rel='bookmark' title='Permanent Link: [Python] 在Python中使用中文'>[Python] 在Python中使用中文</a></li>
<li><a href='http://blog.lauct.org/archives/882' rel='bookmark' title='Permanent Link: Perl, Python, Ruby 比較'>Perl, Python, Ruby 比較</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<ul style="line-height: 1.5em; list-style-type: square; margin-top: 0.3em; margin-right: 0px; margin-bottom: 0px; margin-left: 1.5em; list-style-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/bullet.gif); padding: 0px;">
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/en/Newsletter/Tech.-article/" rel="nofollow" href="http://www.openfoundry.org/en/Newsletter/Tech.-article/">如何像電腦科學家一樣思考</a>How to Think Like a Computer Scientist (中譯版) <a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://openbookproject.net/thinkcs/python/english2e/index.xhtml" rel="nofollow" href="http://openbookproject.net/thinkcs/python/english2e/index.xhtml">原文</a></li>
</ul>
<dl style="margin-top: 0.2em; margin-bottom: 0.5em;">
<dd style="line-height: 1.5em; margin-left: 2em; margin-bottom: 0.1em;">這是一本不錯的 Python 工具書，適合 Python 初學者閱讀的入門書</dd>
<dd style="line-height: 1.5em; margin-left: 2em; margin-bottom: 0.1em;">中譯版</p>
<ul style="line-height: 1.5em; list-style-type: square; margin-top: 0.3em; margin-right: 0px; margin-bottom: 0px; margin-left: 1.5em; list-style-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/bullet.gif); padding: 0px;">
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1527/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1527/task,view/">如何像電腦科學家一樣思考</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1560/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1560/task,view/">如何像電腦科學家一樣思考 | 1.程式之道</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1587/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1587/task,view/">如何像電腦科學家一樣思考 | 2. 變數、表達式及陳述</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1629/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1629/task,view/">如何像電腦科學家一樣思考 | 3. 函數</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1694/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1694/task,view/">如何像電腦科學家一樣思考 | 4. 條件式</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1771/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1771/task,view/">如何像電腦科學家一樣思考 | 5. 多效函數</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1807/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1807/task,view/">如何像電腦科學家一樣思考 | 6. 重複</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1863/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1863/task,view/">如何像電腦科學家一樣思考 | 7. 字串</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1950/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,1950/task,view/">如何像電腦科學家一樣思考 | 8. 案例研究： Catch</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,2011/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,2011/task,view/">如何像電腦科學家一樣思考 | 9. Tuple</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,2044/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,2044/task,view/">如何像電腦科學家一樣思考 |10. 模組和檔案</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,2070/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,2070/task,view/">如何像電腦科學家一樣思考 |11. 檔案和例外</a></li>
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,2088/task,view/" rel="nofollow" href="http://www.openfoundry.org/component/option,com_content/Itemid,334/id,2088/task,view/">如何像電腦科學家一樣思考 |12. 類別與物件</a></li>
</ul>
</dd>
</dl>
<ul style="line-height: 1.5em; list-style-type: square; margin-top: 0.3em; margin-right: 0px; margin-bottom: 0px; margin-left: 1.5em; list-style-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/bullet.gif); padding: 0px;">
<li style="margin-bottom: 0.1em;"><a style="text-decoration: none; color: #3366bb; background-image: url(http://w3.sy3es.tnc.edu.tw/wiki/skins/monobook/external.png); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; padding-top: 0px; padding-right: 13px; padding-bottom: 0px; padding-left: 0px; background-position: 100% 50%;" title="http://pydoing.blogspot.com/" rel="nofollow" href="http://pydoing.blogspot.com/">電腦做什麼事</a></li>
</ul>
<dl style="margin-top: 0.2em; margin-bottom: 0.5em;">
<dd style="line-height: 1.5em; margin-left: 2em; margin-bottom: 0.1em;"><strong>電腦做什麼事</strong>是一系列Python程式語言的教學文章，我們嘗試提供給讀者以簡單、直覺的方式學習程式語言，進而了解體會電腦背後運作的道理。</dd>
</dl>
<p>&#8211;</p>
<p>來源：<a href="http://w3.sy3es.tnc.edu.tw/wiki/index.php/學習寫程式">學習寫程式 &#8211; Sy3es_wiki</a></p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1472' rel='bookmark' title='Permanent Link: [MacPorts][Python] python_select：選擇 Python 版本+手動指定'>[MacPorts][Python] python_select：選擇 Python 版本+手動指定</a></li>
<li><a href='http://blog.lauct.org/archives/1464' rel='bookmark' title='Permanent Link: [Python] 在Python中使用中文'>[Python] 在Python中使用中文</a></li>
<li><a href='http://blog.lauct.org/archives/882' rel='bookmark' title='Permanent Link: Perl, Python, Ruby 比較'>Perl, Python, Ruby 比較</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1458/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[轉載] PHP:檔案處理</title>
		<link>http://blog.lauct.org/archives/1456</link>
		<comments>http://blog.lauct.org/archives/1456#comments</comments>
		<pubDate>Mon, 02 Nov 2009 02:01:54 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[Web開發]]></category>
		<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1456</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
PHP 檔案處理 讀檔: 1.fopen 範例: &#60;?php $handle = fopen&#40;&#34;open_file.txt&#34;, &#34;r&#34;&#41;; if&#40; $handle === FALSE&#41; &#123; echo &#34;Open File Fail&#34; . &#34;&#60;br&#62;&#34;; &#125; else &#123; echo &#34;Open File Success&#34; . &#34;&#60;br&#62;&#34;; while &#40;!feof&#40;$handle&#41;&#41; &#123; $current_line = fgets&#40;$handle&#41;; echo $current_line . &#34;&#60;br&#62;&#34;; &#125; &#125; &#160; ?&#62; 2.file_get_contents 範例: &#60;?php &#160; $handle = file_get_contents&#40;'open_file.txt'&#41;; echo $handle; &#160; ?&#62; [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1464' rel='bookmark' title='Permanent Link: [Python] 在Python中使用中文'>[Python] 在Python中使用中文</a></li>
<li><a href='http://blog.lauct.org/archives/438' rel='bookmark' title='Permanent Link: Just in Love 愛在其衷Pixnet分站'>Just in Love 愛在其衷Pixnet分站</a></li>
<li><a href='http://blog.lauct.org/archives/1545' rel='bookmark' title='Permanent Link: [URLs] Android emulator 常用指令'>[URLs] Android emulator 常用指令</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p>PHP 檔案處理</p>
<p>讀檔:</p>
<p>1.fopen</p>
<p>範例:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;open_file.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;r&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$handle</span> <span style="color: #339933;">===</span> <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>    
    <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Open File Fail&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>    
    <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Open File Success&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">feof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$current_line</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fgets</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">echo</span> <span style="color: #000088;">$current_line</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>2.file_get_contents</p>
<p>範例:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open_file.txt'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #000088;">$handle</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>=========================================================</p>
<p>寫檔:</p>
<p>1.fwrite</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open_file.txt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;test1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>ps:fwrite 是沒有加換行字元,如果要換行必須加上 \n 處理</p>
<p>2.file_put_contents</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'open_file.txt'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$current_line</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;line1<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    file_put_contents<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$current_line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>source: <a href="http://yuanann.pixnet.net/blog/post/25305556">PHP:檔案處理 @ 拉不拉多的夢幻世界 :: 痞客邦 PIXNET ::</a></p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1464' rel='bookmark' title='Permanent Link: [Python] 在Python中使用中文'>[Python] 在Python中使用中文</a></li>
<li><a href='http://blog.lauct.org/archives/438' rel='bookmark' title='Permanent Link: Just in Love 愛在其衷Pixnet分站'>Just in Love 愛在其衷Pixnet分站</a></li>
<li><a href='http://blog.lauct.org/archives/1545' rel='bookmark' title='Permanent Link: [URLs] Android emulator 常用指令'>[URLs] Android emulator 常用指令</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1456/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Perl/Tk] 學習筆記 1: Hello World</title>
		<link>http://blog.lauct.org/archives/1451</link>
		<comments>http://blog.lauct.org/archives/1451#comments</comments>
		<pubDate>Wed, 28 Oct 2009 07:19:00 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Perl/Tk]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1451</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
Hello World 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #!/usr/bin/env perl &#160; # helloworld.pl # # Created by Chun-Ting Liu on 2009-10-28 &#160; require 5.008008; use warnings; use strict; use Tk; my $mw = MainWindow-&#62;new; #建立一個視窗 $mw-&#62;title&#40;&#34;Hello World&#34;&#41;; #改變視窗標題文字，若沒有指定則預設為檔名（首字母會自動大寫）。title method不是必要的但會比較好看。 $mw-&#62;Button&#40;-text =&#62; &#34;Done!&#34;, -command =&#62; sub [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/70' rel='bookmark' title='Permanent Link: NK手打widget第三發：NK 訳丸中日翻譯'>NK手打widget第三發：NK 訳丸中日翻譯</a></li>
<li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<h3>Hello World</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env perl</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># helloworld.pl</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Created by Chun-Ting Liu on 2009-10-28</span>
&nbsp;
<span style="color: #000066;">require</span> <span style="color: #cc66cc;">5.008008</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Tk<span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mw</span> <span style="color: #339933;">=</span> MainWindow<span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">#建立一個視窗</span>
<span style="color: #0000ff;">$mw</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">title</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Hello World&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">#改變視窗標題文字，若沒有指定則預設為檔名（首字母會自動大寫）。title method不是必要的但會比較好看。</span>
<span style="color: #0000ff;">$mw</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">Button</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>text <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;Done!&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #339933;">-</span>command <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">exit</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">#建立一個寫著Done!的Button widget，點擊後則執行 exit。</span>
MainLoop<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">#開始GUI事件處理</span></pre></td></tr></table></div>

<p><a href="http://blog.lauct.org/wp-content/uploads/2009/10/圖片-11.png"><img src="http://blog.lauct.org/wp-content/uploads/2009/10/圖片-11.png" alt="Hello World" title="Hello World" width="292" height="86" class="aligncenter size-full wp-image-1453" /></a></p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/70' rel='bookmark' title='Permanent Link: NK手打widget第三發：NK 訳丸中日翻譯'>NK手打widget第三發：NK 訳丸中日翻譯</a></li>
<li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1451/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[Perl][Video][Tutorial] 探索Perl的世界匯總</title>
		<link>http://blog.lauct.org/archives/1441</link>
		<comments>http://blog.lauct.org/archives/1441#comments</comments>
		<pubDate>Sat, 17 Oct 2009 19:40:18 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1441</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
探索Perl的世界 -1  本集是第一集，介紹Perl的概述。 探索Perl的世界 -2  本集是第二集，介紹Perl的簡單變量。 探索Perl的世界 -3  本集是第三集，介紹Perl的字符串變量。 探索Perl的世界 -4  本集是第四集，介紹字符串變量和小結 探索Perl的世界 -5  本集是第五集，這一章是講perl中的運算符，這一節為第一段，講算術運算符，比較運算符和邏輯運算符。 探索Perl的世界 -6  本集是第六集，這一章是講perl中的運算符。 探索Perl的世界 -7  本集是第七集，這一章是講perl中的運算符優先級。 探索Perl的世界 -8  本集是第八集，這一章是講perl中的控制結構。 探索Perl的世界 -9  本集是第九集，這一章是講perl中的控制結構。 探索Perl的世界 &#8211; 10 探索Perl的世界 &#8211; 11 探索Perl的世界 &#8211; 12 Related posts:[Perl][轉錄] 實例說明 Perl 特殊變數 [Perl] 安裝 Perl CPAN 模組方法筆記 [Perl] BPS-FlickrFilter


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/1449' rel='bookmark' title='Permanent Link: [Perl] 安裝 Perl CPAN 模組方法筆記'>[Perl] 安裝 Perl CPAN 模組方法筆記</a></li>
<li><a href='http://blog.lauct.org/archives/1436' rel='bookmark' title='Permanent Link: [Perl] BPS-FlickrFilter'>[Perl] BPS-FlickrFilter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p><a href="http://www.boobooke.com/v/bbk2869">探索Perl的世界 -1  本集是第一集，介紹Perl的概述。</a><br />
<a href="http://www.boobooke.com/v/bbk2969">探索Perl的世界 -2  本集是第二集，介紹Perl的簡單變量。</a><br />
<a href="http://www.boobooke.com/v/bbk3074">探索Perl的世界 -3  本集是第三集，介紹Perl的字符串變量。</a><br />
<a href="http://www.boobooke.com/v/bbk3195">探索Perl的世界 -4  本集是第四集，介紹字符串變量和小結</a><br />
<a href="http://www.boobooke.com/v/bbk3335">探索Perl的世界 -5  本集是第五集，這一章是講perl中的運算符</a>，這一節為第一段，講算術運算符，比較運算符和邏輯運算符。<br />
<a href="http://www.boobooke.com/v/bbk3370">探索Perl的世界 -6  本集是第六集，這一章是講perl中的運算符</a>。<br />
<a href="http://www.boobooke.com/v/bbk3403">探索Perl的世界 -7  本集是第七集，這一章是講perl中的運算符優先級。</a><br />
<a href="http://www.boobooke.com/v/bbk3428">探索Perl的世界 -8  本集是第八集，這一章是講perl中的控制結構。</a><br />
<a href="http://www.boobooke.com/v/bbk3448">探索Perl的世界 -9  本集是第九集，這一章是講perl中的控制結構。</a><br />
<a href="http://www.boobooke.com/v/bbk3529">探索Perl的世界 &#8211; 10</a><br />
<a href="http://www.boobooke.com/v/bbk3530">探索Perl的世界 &#8211; 11</a><br />
<a href="http://www.boobooke.com/v/bbk3531">探索Perl的世界 &#8211; 12</a></p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/1449' rel='bookmark' title='Permanent Link: [Perl] 安裝 Perl CPAN 模組方法筆記'>[Perl] 安裝 Perl CPAN 模組方法筆記</a></li>
<li><a href='http://blog.lauct.org/archives/1436' rel='bookmark' title='Permanent Link: [Perl] BPS-FlickrFilter'>[Perl] BPS-FlickrFilter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1441/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Perl][轉錄] 實例說明 Perl 特殊變數</title>
		<link>http://blog.lauct.org/archives/1439</link>
		<comments>http://blog.lauct.org/archives/1439#comments</comments>
		<pubDate>Sat, 17 Oct 2009 19:11:26 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1439</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
先來一個例子吧 #!/usr/bin/perl use warnings; @array = qw(a b c d); foreach (@array) { print $_,” “; } 例子的作用就是定義一個數組並把其中的元素打印出來，這裡需要注意的是foreach循環部分，foreach循環的標準格式應該是： foreach $element (@array){ …… } 其中數組@array將其中的元素依次賦值給$element，但是在上面那個程序中，我並沒有這樣做，在程序中，我就使用到了perl中內置的一個特殊變數 $_ 。 在程序第五行中：foreach (@array) 實際上就是等於 foreach $_ (@array)，在這裡，$_是預設是輸入/輸出，因此，如果在程序中有類似的沒有明確聲明的變數位置的時候，就有可能能使用$_代替。 再看另外一個內置變數 perl -e “sleep(5);print qq(The PID of process perl.exe is : $$)”; 這是一句命令行上使用的perl程序，作用就是打印出一段話：print qq(The PID of process perl.exe is : $$) ，在這裡，存在著特殊變數$$ ； $$是當前perl解析器的進程ID（即，PID），大家可以將在段程序寫在命令行上，該程序會在perl解析器運行5秒後打印出perl解析器的進程ID，大家可以在程序運行期間通過查看進程列表來確定打印結果是否正確（^_^不會錯的）。 [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
<li><a href='http://blog.lauct.org/archives/1436' rel='bookmark' title='Permanent Link: [Perl] BPS-FlickrFilter'>[Perl] BPS-FlickrFilter</a></li>
<li><a href='http://blog.lauct.org/archives/1438' rel='bookmark' title='Permanent Link: [Perl] 常見特殊變數'>[Perl] 常見特殊變數</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">先來一個例子吧</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span id="more-1439"></span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #666666; background-color: #ffffff; margin: 0px;"><em>#!/usr/bin/perl</em></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #000000;"><strong>use</strong></span> warnings<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">@array</span> <span style="color: #53953c;">=</span> <span style="color: #000e62;">qw</span><span style="color: #43941f;">(</span>a b c d<span style="color: #43941f;">)</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b3ae2a; background-color: #ffffff; margin: 0px;">foreach<span style="color: #0f0000;"> </span><span style="color: #43941f;">(</span><span style="color: #0024f4;">@array</span><span style="color: #43941f;">)</span><span style="color: #0f0000;"> </span><span style="color: #43941f;">{</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; padding-left: 30px; margin: 0px;">print<span style="color: #0f0000;"> </span><span style="color: #0024f4;">$_</span><span style="color: #53953c;">,</span><span style="color: #e1251d;">” “</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">}</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">例子的作用就是定義一個數組並把其中的元素打印出來，這裡需要注意的是<span style="font: normal normal normal 16px/normal Courier; color: #b3ae2a;">foreach</span>循環部分，<span style="font: normal normal normal 16px/normal Courier; color: #b3ae2a;">foreach</span>循環的標準格式應該是：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0024f4; background-color: #ffffff; margin: 0px;"><span style="color: #b3ae2a;">foreach</span><span style="color: #0f0000;"> </span>$element<span style="color: #0f0000;"> </span><span style="color: #43941f;">(</span>@array<span style="color: #43941f;">){</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; padding-left: 30px; margin: 0px;">……</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">}</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">其中數組<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">@array</span>將其中的元素依次賦值給<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$element</span>，但是在上面那個程序中，我並沒有這樣做，在程序中，我就使用到了<span style="font: normal normal normal 16px/normal Courier;">perl</span>中內置的一個特殊變數<span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$_</span><span style="font: normal normal normal 16px/normal Courier;"> </span>。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">在程序第五行中：<span style="font: normal normal normal 16px/normal Courier; color: #b3ae2a;">foreach</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">(</span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">@array</span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">)</span><span style="font: normal normal normal 16px/normal Courier;"> </span>實際上就是等於<span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #b3ae2a;">foreach</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$_</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">(</span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">@array</span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">)</span>，在這裡，<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$_</span>是預設是輸入<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">/</span>輸出，因此，如果在程序中有類似的沒有明確聲明的變數位置的時候，就有可能能使用<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$_</span>代替。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">再看另外一個內置變數</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">perl </span><span style="color: #53953c;">-</span><span style="color: #0f0000;">e </span>“sleep(5);print qq(The PID of process perl.exe is : $$)”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #53953c;"><br />
</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal 'LiHei Pro';">這是一句命令行上使用的</span>perl<span style="font: normal normal normal 16px/normal 'LiHei Pro';">程序，作用就是打印出一段話：</span><span style="color: #000e62;">print</span> <span style="color: #000e62;">qq</span><span style="color: #43941f;">(</span>The PID of process perl.exe is <span style="color: #53953c;">:</span> <span style="color: #0024f4;">$$</span><span style="color: #43941f;">)</span> <span style="font: normal normal normal 16px/normal 'LiHei Pro';">，在這裡，存在著特殊變數</span><span style="color: #0024f4;">$$</span> <span style="font: normal normal normal 16px/normal 'LiHei Pro';">；</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal 'LiHei Pro';"><br />
</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$$</span>是當前<span style="font: normal normal normal 16px/normal Courier;">perl</span>解析器的進程<span style="font: normal normal normal 16px/normal Courier;">ID</span>（即，<span style="font: normal normal normal 16px/normal Courier;">PID</span>），大家可以將在段程序寫在命令行上，該程序會在<span style="font: normal normal normal 16px/normal Courier;">perl</span>解析器運行<span style="font: normal normal normal 16px/normal Courier; color: #b96ec7;">5</span>秒後打印出<span style="font: normal normal normal 16px/normal Courier;">perl</span>解析器的進程<span style="font: normal normal normal 16px/normal Courier;">ID</span>，大家可以在程序運行期間通過查看進程列表來確定打印結果是否正確（<span style="font: normal normal normal 16px/normal Courier;">^_^</span>不會錯的）。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">接下來是一個用來返回錯誤信息（或是錯誤號）的特殊變數。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">為了省事，不寫程序了，還是來個命令行的吧</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">perl </span><span style="color: #53953c;">-</span><span style="color: #0f0000;">e </span>“opendir FH,’c: one’ or die qq(can’t open:$!);”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #53953c;"><br />
</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">這句話就是要打開<span style="font: normal normal normal 16px/normal Courier;">C</span>盤下的一個<span style="font: normal normal normal 16px/normal Courier;">none</span>目錄（而實際上我的<span style="font: normal normal normal 16px/normal Courier;">C</span>盤中並沒有此目錄，之所以這樣寫的目的就是為了引起一個程序中的錯誤信息），如果沒有打開的話，會執行後面的<span style="font: normal normal normal 16px/normal Courier; color: #000e62;">die</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #000e62;">qq</span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">(</span><span style="font: normal normal normal 16px/normal Courier; color: #0a0b0f;">can’t open:$!</span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">)</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #17323b; background-color: #ffffff; margin: 0px;">在這裡，<span style="font: normal normal normal 16px/normal Courier;">$!</span>就指明瞭錯誤信息的內容，命令行會返回錯誤信息：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #17323b;">can’t</span> <span style="color: #000e62;">open</span><span style="color: #53953c;">:</span>No such file <span style="color: #b3ae2a;">or</span> directory at <span style="color: #53953c;">-</span>e line 1.</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$!</span>在<span style="font: normal normal normal 16px/normal Courier; color: #000e62;">open</span>或是<span style="font: normal normal normal 16px/normal Courier; color: #000e62;">opendir</span>中用的比較多（無論是打開文件還是管道或是其他）。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">來個例子，說一個有意思的特殊內置變數</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #53953c;">=</span><span style="color: #0f0000;"> </span>“C:<strong>\t</strong>est.txt”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">{</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #000e62;">open</span><span style="color: #0f0000;"> FH</span><span style="color: #53953c;">,</span><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #b3ae2a;">or</span><span style="color: #0f0000;"> </span><span style="color: #000e62;">die</span><span style="color: #0f0000;"> </span>“can’t open:$!”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0024f4; background-color: #ffffff; margin: 0px;"><span style="color: #b3ae2a;">my</span><span style="color: #0f0000;"> </span>$line<span style="color: #0f0000;"> </span><span style="color: #53953c;">=</span><span style="color: #0f0000;"> </span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">close<span style="color: #0f0000;"> FH</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">print<span style="color: #0f0000;"> </span><span style="color: #0024f4;">$line</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">}</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #000e62;">print</span><span style="color: #0f0000;"> </span>“#===========================# “<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">{</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">undef<span style="color: #0f0000;"> </span><span style="color: #0024f4;">$/</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #000e62;">open</span><span style="color: #0f0000;"> FH</span><span style="color: #53953c;">,</span><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #b3ae2a;">or</span><span style="color: #0f0000;"> </span><span style="color: #000e62;">die</span><span style="color: #0f0000;"> </span>“can’t open:$!”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0024f4; background-color: #ffffff; margin: 0px;"><span style="color: #b3ae2a;">my</span><span style="color: #0f0000;"> </span>$line<span style="color: #0f0000;"> </span><span style="color: #53953c;">=</span><span style="color: #0f0000;"> </span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">close<span style="color: #0f0000;"> FH</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">print<span style="color: #0f0000;"> </span><span style="color: #0024f4;">$line</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">}</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #53953c; background-color: #ffffff; margin: 0px;">=================================</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">C<span style="font: normal normal normal 16px/normal 'LiHei Pro';">盤下的</span>test.txt<span style="font: normal normal normal 16px/normal 'LiHei Pro';">的內容是：</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">111111111111111111111111111</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">222222222222222222222222222</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">333333333333333333333333333</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #53953c; background-color: #ffffff; margin: 0px;">=================================</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">好，程序的運行結果是：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">111111111111111111111111111</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #666666; background-color: #ffffff; margin: 0px;"><em>#===========================#</em></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">111111111111111111111111111</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">222222222222222222222222222</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">333333333333333333333333333</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">程序就不多廢話了，作用就是讀文件，關鍵部分在<span style="font: normal normal normal 16px/normal Courier;">“</span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$line</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">=</span><span style="font: normal normal normal 16px/normal Courier;"> ”</span>，尖括號操作符（即，<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">&lt;&gt;</span>）作用是讀取一行文件內容（相信大多數教程或是書上都是這麼寫的），但是，這裡所說的一行，實際上是有一個標準的，那就是當<span style="font: normal normal normal 16px/normal Courier;">perl</span>在遇到了換行符後，邊認為是一行，而換行符預設情況下是由於<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span>這個特殊變數定義的，是預設值。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">也就是說，<span style="font: normal normal normal 16px/normal Courier;">perl </span>在每次使用<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">&lt;&gt;</span>操作符讀文件的時候，會先從<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span>中獲得一個叫做<span style="font: normal normal normal 16px/normal Courier;">“</span>分隔符<span style="font: normal normal normal 16px/normal Courier;">”</span>的東西，並以該分隔符為標記來讀取文件，如果按預設的<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span>來說，這個分割符就是一個換行符，所以，預設時，<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">&lt;&gt;</span>操作符才會每次讀取一行文本。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">在給出的例子中，有這樣一句<span style="font: normal normal normal 16px/normal Courier;"> </span>：<span style="font: normal normal normal 16px/normal Courier; color: #000e62;">undef</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span><span style="font: normal normal normal 16px/normal Courier;"> </span>，也就是將<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span>設置為未定義的值，這樣一來呢，<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span>就不再起作用了，因此，大家可以看到，第二次進行同樣的操作的時候，<span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">&lt;&gt;</span>操作符就不再是只讀一行而是將文件內容全部讀出來了。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">接下來看一個會受到<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span>影響的內置變數，還是先說實例：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #53953c;">=</span><span style="color: #0f0000;"> </span>“C:<strong>\t</strong>est.txt”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #000e62;">open</span><span style="color: #0f0000;"> FH</span><span style="color: #53953c;">,</span><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #b3ae2a;">or</span><span style="color: #0f0000;"> </span><span style="color: #000e62;">die</span><span style="color: #0f0000;"> </span>“can’t open:$!”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b3ae2a; background-color: #ffffff; margin: 0px;">while<span style="color: #0f0000;"> </span><span style="color: #43941f;">()</span><span style="color: #0f0000;"> </span><span style="color: #43941f;">{</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; padding-left: 30px; margin: 0px;"><span style="color: #000e62;">print</span><span style="color: #0f0000;"> </span>“line $. is:$_”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">}</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">close<span style="color: #0f0000;"> FH</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;"><span style="color: #53953c;"><br />
</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000;">先來看循環中的：</span><span style="color: #000e62;">print</span><span style="color: #0f0000;"> </span>“line $. is:$_”</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">程序的作用是讀文件，並且，將文件逐行賦值給<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$_</span>（因為只用了<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">&lt;&gt;</span>操作符而沒有指定內賦值變數，因此，預設就是賦值給了<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$_</span>）；</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">但是這裡除了<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$_</span>，還有一個變數<span style="font: normal normal normal 16px/normal Courier;">“</span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span><span style="font: normal normal normal 16px/normal Courier;">”</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">我們來看一下結果：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">line </span>1<span style="color: #0f0000;"> is</span><span style="color: #53953c;">:</span>111111111111111111111111111</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">line </span>2<span style="color: #0f0000;"> is</span><span style="color: #53953c;">:</span>222222222222222222222222222</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">line </span>3<span style="color: #0f0000;"> is</span><span style="color: #53953c;">:</span>333333333333333333333333333</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">可見，變數<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span>的作用是一個類似計數器的東西，但是，為甚麼剛開始我說<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span>會受到<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span>變數的影響呢<span style="font: normal normal normal 16px/normal Courier;"> </span>？</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">將上面的例子稍做修改，再看一下：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #53953c;">=</span><span style="color: #0f0000;"> </span>“C:<span style="color: #001692;"><strong>\t</strong></span>est.txt”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #666666; background-color: #ffffff; margin: 0px;"><span style="color: #000e62;">undef</span><span style="color: #0f0000;"> </span><span style="color: #0024f4;">$/</span><span style="color: #53953c;">;</span><span style="color: #0f0000;"> </span><em># </em><span style="font: normal normal normal 16px/normal 'LiHei Pro';">注意，多加了這一行</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #000e62;">open</span><span style="color: #0f0000;"> FH</span><span style="color: #53953c;">,</span><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #b3ae2a;">or</span><span style="color: #0f0000;"> </span><span style="color: #000e62;">die</span><span style="color: #0f0000;"> </span>“can’t open:$!”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b3ae2a; background-color: #ffffff; margin: 0px;">while<span style="color: #0f0000;"> </span><span style="color: #43941f;">()</span><span style="color: #0f0000;"> </span><span style="color: #43941f;">{</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; padding-left: 30px; margin: 0px;"><span style="color: #000e62;">print</span><span style="color: #0f0000;"> </span>“line $. is:$_”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">}</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">close<span style="color: #0f0000;"> FH</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;"><span style="color: #53953c;"><br />
</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">第二行多加了一句<span style="font: normal normal normal 16px/normal Courier; color: #000e62;">undef</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">;</span><span style="font: normal normal normal 16px/normal Courier;"> </span>，上面已經說過它的作用了，來看一下這段程序運行的結果：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">line </span>1<span style="color: #0f0000;"> is</span><span style="color: #53953c;">:</span>111111111111111111111111111</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">222222222222222222222222222</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">333333333333333333333333333</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">本來應該是三行的文本，不但被一次性打印出來，而且還指明瞭<span style="font: normal normal normal 16px/normal Courier;">“line </span><span style="font: normal normal normal 16px/normal Courier; color: #b96ec7;">1</span><span style="font: normal normal normal 16px/normal Courier;">”</span>（看來程序認為這個文本只有一行），為甚麼？</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">這是因為<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span>變數並不是一個單純的行計數器，確切地說，可以說<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span>是一個對<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span>計數器，我們再來看一段程序大概就會明白了：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #53953c;">=</span><span style="color: #0f0000;"> </span>“C:<span style="color: #001692;"><strong>\a</strong></span>.txt”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #666666; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span><span style="font: normal normal normal 16px/normal Courier; color: #0f0000;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">=</span><span style="font: normal normal normal 16px/normal Courier; color: #0f0000;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #e1251d;">“;”</span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">;</span><span style="font: normal normal normal 16px/normal Courier; color: #0f0000;"> </span><span style="font: normal normal normal 16px/normal Courier;"><em># </em></span>注意這裡，這裡我並將<span style="font: normal normal normal 16px/normal Courier;"><em>$/</em></span>設置為未定義，而是給其賦值為分號</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #000e62;">open</span><span style="color: #0f0000;"> FH</span><span style="color: #53953c;">,</span><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #b3ae2a;">or</span><span style="color: #0f0000;"> </span><span style="color: #000e62;">die</span><span style="color: #0f0000;"> </span>“can’t open:$!”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b3ae2a; background-color: #ffffff; margin: 0px;">while<span style="color: #0f0000;"> </span><span style="color: #43941f;">()</span><span style="color: #0f0000;"> </span><span style="color: #43941f;">{</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; padding-left: 30px; margin: 0px;"><span style="color: #000e62;">print</span><span style="color: #0f0000;"> </span>“line $. is:$_ “<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">}</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">close<span style="color: #0f0000;"> FH</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;"><span style="color: #53953c;"><br />
</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">再看一下<span style="font: normal normal normal 16px/normal Courier;">C</span>盤下的<span style="font: normal normal normal 16px/normal Courier;">a.txt</span>的內容：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">ddd<span style="color: #53953c;">;</span>bbb<span style="color: #53953c;">;</span>ccc<span style="color: #53953c;">;</span>fff<span style="color: #53953c;">;</span>eee<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">就這麼簡單了。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">看一下運行結果：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">line <span style="color: #b96ec7;">1</span> is<span style="color: #53953c;">:</span>ddd<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">line <span style="color: #b96ec7;">2</span> is<span style="color: #53953c;">:</span>bbb<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">line <span style="color: #b96ec7;">3</span> is<span style="color: #53953c;">:</span>ccc<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">line <span style="color: #b96ec7;">4</span> is<span style="color: #53953c;">:</span>fff<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">line <span style="color: #b96ec7;">5</span> is<span style="color: #53953c;">:</span>eee<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">看過這段程序應該就明白了吧。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">好，<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span>已經講得差不多了，接下來再說一個它的特性，仍然是看程序說話：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #53953c;">=</span><span style="color: #0f0000;"> </span>“C:<strong>\t</strong>est.txt”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #000e62;">open</span><span style="color: #0f0000;"> FH</span><span style="color: #53953c;">,</span><span style="color: #0024f4;">$text</span><span style="color: #0f0000;"> </span><span style="color: #b3ae2a;">or</span><span style="color: #0f0000;"> </span><span style="color: #000e62;">die</span><span style="color: #0f0000;"> </span>“can’t open:$!”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b3ae2a; background-color: #ffffff; margin: 0px;">while<span style="color: #0f0000;"> </span><span style="color: #43941f;">()</span><span style="color: #0f0000;"> </span><span style="color: #43941f;">{</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; padding-left: 30px; margin: 0px;"><span style="color: #000e62;">print</span><span style="color: #0f0000;"> </span>“line $. is:$_ “<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #43941f; background-color: #ffffff; margin: 0px;">}</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">print<span style="color: #0f0000;"> </span><span style="color: #e1251d;">” “</span><span style="color: #53953c;">,</span><span style="color: #0024f4;">$.</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">close<span style="color: #0f0000;"> FH</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;">print<span style="color: #0f0000;"> </span><span style="color: #e1251d;">” “</span><span style="color: #53953c;">,</span><span style="color: #0024f4;">$.</span><span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #000e62; background-color: #ffffff; margin: 0px;"><span style="color: #53953c;"><br />
</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">這個程序要注意的是最後三行中的兩個<span style="font: normal normal normal 16px/normal Courier; color: #000e62;">print</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #e1251d;">” “</span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">,</span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">;</span>（一個是在關閉文件前，另外一個則是在關閉文件後）。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">看一下執行結果：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">line </span>1<span style="color: #0f0000;"> is</span><span style="color: #53953c;">:</span>111111111111111111111111111</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">line </span>2<span style="color: #0f0000;"> is</span><span style="color: #53953c;">:</span>222222222222222222222222222</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">line </span>3<span style="color: #0f0000;"> is</span><span style="color: #53953c;">:</span>333333333333333333333333333</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">3</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #b96ec7; background-color: #ffffff; margin: 0px;">0</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">結果的前三行剛才就已經知道了，這不是我們關心的，我們應該關心的是最後兩行結果（即兩個<span style="font: normal normal normal 16px/normal Courier; color: #000e62;">print</span><span style="font: normal normal normal 16px/normal Courier;"> </span><span style="font: normal normal normal 16px/normal Courier; color: #e1251d;">” “</span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">,</span><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span><span style="font: normal normal normal 16px/normal Courier; color: #53953c;">;</span>的結果）；</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span>變數是具有記憶性的（從原理上來將，它是一個包變數），因此，在關閉文件前打印會發現，它的值是還沒有變化的（這時的值和最後一次讀完文件的值均為<span style="font: normal normal normal 16px/normal Courier; color: #b96ec7;">3</span>）；</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">而在關閉文件後，該變數又被重新初始化為<span style="font: normal normal normal 16px/normal Courier; color: #b96ec7;">0</span>了。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">這個特性大家注意一下就可以了，因為其中的原理涉及到了<span style="font: normal normal normal 16px/normal Courier;">perl</span>的作用域和包的一些知識，不是很容易說清楚，所以就不說了，如果對包和作用域有瞭解的讀者對這部分即使我不講他們也應該能理解的。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">再說最後一個吧</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">說一個用來簡單判斷操作系統類型的，看個例子：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #e1251d; background-color: #ffffff; margin: 0px;"><span style="color: #0f0000;">C</span><span style="color: #53953c;">:&gt;</span><span style="color: #0f0000;">perl </span><span style="color: #53953c;">-</span><span style="color: #0f0000;">e </span>“print $^O;”<span style="color: #53953c;">;</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">MSWin32</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">注意，這裡這個特殊變數<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^O</span><span style="font: normal normal normal 16px/normal Courier;"> </span>最後一個字符是字母<span style="font: normal normal normal 16px/normal Courier;">O</span>，且大寫。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal 'LiHei Pro';">如果是在</span>linux<span style="font: normal normal normal 16px/normal 'LiHei Pro';">下的話，結果就不是</span>MSWin32<span style="font: normal normal normal 16px/normal 'LiHei Pro';">了，而是</span>Linux <span style="font: normal normal normal 16px/normal 'LiHei Pro';">；</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">這是一個判斷環境的變數，簡單實用。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier;">perl</span>的內置特殊變數還有很多的，例如常用的還有<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">@_</span>、<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">@ARGV</span>、<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$ARGV</span>、<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">%INC</span>、<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">%ENV</span>等等，有很多，不可能一一列舉了，這裡給出一個比較有總結性的列表，是<span style="font: normal normal normal 16px/normal Courier;">chinaunix</span>上<span style="font: normal normal normal 16px/normal Courier;">perl</span>社區的一個網友總結的，還算比較全：</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$-</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前頁可打印的行數<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">,</span>屬於<span style="font: normal normal normal 16px/normal Courier;">Perl</span>格式系統的一部分<span style="font: normal normal normal 16px/normal Courier;"> </span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$!</span><span style="font: normal normal normal 16px/normal Courier;"> </span>根據上下文內容返回錯誤號或者錯誤串<span style="font: normal normal normal 16px/normal Courier;"> </span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$”</span><span style="font: normal normal normal 16px/normal Courier;"> </span>列表分隔符<span style="font: normal normal normal 16px/normal Courier;"> </span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$#</span><span style="font: normal normal normal 16px/normal Courier;"> </span>打印數字時預設的數字輸出格式<span style="font: normal normal normal 16px/normal Courier;"> </span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$$</span> Perl<span style="font: normal normal normal 16px/normal 'LiHei Pro';">解釋器的進程</span>ID</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$%</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前輸出通道的當前頁號</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$&amp;</span><span style="font: normal normal normal 16px/normal Courier;"> </span>與上個格式匹配的字符串</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$(</span> <span style="font: normal normal normal 16px/normal 'LiHei Pro';">當前進程的組</span>ID</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$)</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前進程的有效組<span style="font: normal normal normal 16px/normal Courier;">ID</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$*</span><span style="font: normal normal normal 16px/normal Courier;"> </span>設置<span style="font: normal normal normal 16px/normal Courier; color: #b96ec7;">1</span>表示處理多行格式<span style="font: normal normal normal 16px/normal Courier;">.</span>現在多以<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">/</span><span style="font: normal normal normal 16px/normal Courier; color: #000e62;">s</span>和<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">/</span><span style="font: normal normal normal 16px/normal Courier; color: #000e62;">m</span>修飾符取代之<span style="font: normal normal normal 16px/normal Courier;">.</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$,</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前輸出字段分隔符</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$.</span><span style="font: normal normal normal 16px/normal Courier;"> </span>上次閱讀的文件的當前輸入行號</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$/</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前輸入記錄分隔符<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">,</span>預設情況是新行</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$:</span><span style="font: normal normal normal 16px/normal Courier;"> </span>字符設置<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">,</span>此後的字符串將被分開<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">,</span>以填充連續的字段<span style="font: normal normal normal 16px/normal Courier;">.</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$;</span><span style="font: normal normal normal 16px/normal Courier;"> </span>在仿真多維數組時使用的分隔符<span style="font: normal normal normal 16px/normal Courier;">.</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$?</span><span style="font: normal normal normal 16px/normal Courier;"> </span>返回上一個外部命令的狀態</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$@</span><span style="font: normal normal normal 16px/normal Courier;"> Perl</span>解釋器從<span style="font: normal normal normal 16px/normal Courier; color: #000e62;">eval</span>語句返回的錯誤消息</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$[</span><span style="font: normal normal normal 16px/normal Courier;"> </span>數組中第一個元素的索引號</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前輸出記錄的分隔符</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$]</span> Perl<span style="font: normal normal normal 16px/normal 'LiHei Pro';">解釋器的子版本號</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前通道最上面的頁面輸出格式名字</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^A</span><span style="font: normal normal normal 16px/normal Courier;"> </span>打印前用於保存格式化數據的變數</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^D</span><span style="font: normal normal normal 16px/normal Courier;"> </span>調試標誌的值</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^E</span><span style="font: normal normal normal 16px/normal Courier;"> </span>在非<span style="font: normal normal normal 16px/normal Courier;">UNIX</span>環境中的操作系統擴展錯誤信息</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^F</span><span style="font: normal normal normal 16px/normal Courier;"> </span>最大的文件捆述符數值</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^H</span><span style="font: normal normal normal 16px/normal Courier;"> </span>由編譯器激活的語法檢查狀態</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^I</span><span style="font: normal normal normal 16px/normal Courier;"> </span>內置控制編輯器的值</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^L</span><span style="font: normal normal normal 16px/normal Courier;"> </span>發送到輸出通道的走紙換頁符</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^M</span><span style="font: normal normal normal 16px/normal Courier;"> </span>備用內存池的大小</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">$^O</span> <span style="font: normal normal normal 16px/normal 'LiHei Pro';">操作系統名</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^P</span><span style="font: normal normal normal 16px/normal Courier;"> </span>指定當前調試值的內部變數</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^R</span><span style="font: normal normal normal 16px/normal Courier;"> </span>正則表達式塊的上次求值結果</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^S</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前解釋器狀態</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^T</span><span style="font: normal normal normal 16px/normal Courier;"> </span>從新世紀開始算起<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">,</span>腳步本以秒計算的開始運行的時間</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^W</span><span style="font: normal normal normal 16px/normal Courier;"> </span>警告開關的當前值</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$^X</span><span style="font: normal normal normal 16px/normal Courier;"> Perl</span>二進制可執行代碼的名字</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$_</span><span style="font: normal normal normal 16px/normal Courier;"> </span>預設的輸入<span style="font: normal normal normal 16px/normal Courier; color: #53953c;">/</span>輸出和格式匹配空間</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$|</span><span style="font: normal normal normal 16px/normal Courier;"> </span>控制對當前選擇的輸出文件句柄的緩衝</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$~</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前報告格式的名字</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$`</span><span style="font: normal normal normal 16px/normal Courier;"> </span>在上個格式匹配信息前的字符串</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$’</span><span style="font: normal normal normal 16px/normal Courier;"> </span>在上個格式匹配信息後的字符串</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$+</span><span style="font: normal normal normal 16px/normal Courier;"> </span>與上個正則表達式搜索格式匹配的最後一個括號</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$&lt;</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前執行解釋器的用戶的真實<span style="font: normal normal normal 16px/normal Courier;">ID</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$</span><span style="font: normal normal normal 16px/normal Courier;"> </span>含有與上個匹配正則表達式對應括號結果</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$=</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前頁面可打印行的數目</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$&gt;</span><span style="font: normal normal normal 16px/normal Courier;"> </span>當前進程的有效用戶<span style="font: normal normal normal 16px/normal Courier;">ID</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$0</span><span style="font: normal normal normal 16px/normal Courier;"> </span>包含正在執行的腳本的文件名</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$ARGV</span><span style="font: normal normal normal 16px/normal Courier;"> </span>從預設的文件句柄中讀取時的當前文件名</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">%ENV</span> <span style="font: normal normal normal 16px/normal 'LiHei Pro';">環境變數列表</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal Courier; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="color: #0024f4;">%INC</span> <span style="font: normal normal normal 16px/normal 'LiHei Pro';">通過</span><span style="color: #b3ae2a;">do</span><span style="font: normal normal normal 16px/normal 'LiHei Pro';">或</span><span style="color: #000e62;">require</span><span style="font: normal normal normal 16px/normal 'LiHei Pro';">包含的文件列表</span></p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">%SIG</span><span style="font: normal normal normal 16px/normal Courier;"> </span>信號列表及其處理方式</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">@_</span><span style="font: normal normal normal 16px/normal Courier;"> </span>傳給子程序的參數列表</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">@ARGV</span><span style="font: normal normal normal 16px/normal Courier;"> </span>傳給腳本的命令行參數列表</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">@INC</span><span style="font: normal normal normal 16px/normal Courier;"> </span>在導入模塊時需要搜索的目錄列表</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;"><span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$-</span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">[</span><span style="font: normal normal normal 16px/normal Courier; color: #b96ec7;">0</span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">]</span>和<span style="font: normal normal normal 16px/normal Courier; color: #0024f4;">$+</span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">[</span><span style="font: normal normal normal 16px/normal Courier; color: #b96ec7;">0</span><span style="font: normal normal normal 16px/normal Courier; color: #43941f;">]</span><span style="font: normal normal normal 16px/normal Courier;"> </span>代表當前匹配的正則表達式在被匹配的字符串中的起始和終止的位置。</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">&#8211;</p>
<p style="line-height: 15px; font: normal normal normal 16px/normal 'LiHei Pro'; color: #0f0000; background-color: #ffffff; margin: 0px;">via <a href="http://www.diybl.com/course/4_webprogram/cgi/perljs/200862/120206.html">举例说明PERL特殊变量,CGI-Perl技术文章,CGI-Perl系列教程,CGI-Perl</a></p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
<li><a href='http://blog.lauct.org/archives/1436' rel='bookmark' title='Permanent Link: [Perl] BPS-FlickrFilter'>[Perl] BPS-FlickrFilter</a></li>
<li><a href='http://blog.lauct.org/archives/1438' rel='bookmark' title='Permanent Link: [Perl] 常見特殊變數'>[Perl] 常見特殊變數</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1439/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Perl] 常見特殊變數</title>
		<link>http://blog.lauct.org/archives/1438</link>
		<comments>http://blog.lauct.org/archives/1438#comments</comments>
		<pubDate>Sat, 17 Oct 2009 17:33:44 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1438</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
1. $_ $ARG，常常是一個預設變數 &#160; 2. @_ @ARG，子例程參數表 &#160; 3. &#123;row.content&#125; $PROGRAM_NAME，本程序的名字 &#160; 4. @ARGV 本程序的命令行參數表 &#160; 5. $&#34; $LIST_SEPARATOR，數組內插到雙引號字符串中時所用的分隔符， 預設為空格 &#160; 6. $, $OFS，或$OUTPUT_FIELD_SEPARATOR，用於print的輸出字段分隔符， 即一個print語句中用逗號分隔的部分之間用甚麼分隔，預設為無 &#160; 7. $ $ORS，或$OUTPUT_RECORD_SEPARATOR，用於print的輸出記錄分隔符， 即一個print語句結束時末尾添加甚麼，預設為無 &#160; 8. $/ $RS，或$INPUT_RECORD_SEPARATOR，輸入記錄分隔符，改變了readline， &#60;FH&#62;和chomp對於“行”的看法，預設為換行符 &#160; 9. $. $NR，或$INPUT_LINE_NUMBER，最後讀取的“行”號&#40;注意行的概念可能 被8所改變&#41; &#160; 10. $&#124; $AUTOFLUSH，或$OUTPUT_AUTOFLUSH，輸出緩衝區開關，預設為0，即關 &#160; 11. $$ $PID，或$PROCESS_ID，本腳本的進程號&#40;PID&#41; &#160; 12. $! $ERRNO，或$OS_ERROR，上一次系統調用錯誤值 &#160; 13. $@ [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/1449' rel='bookmark' title='Permanent Link: [Perl] 安裝 Perl CPAN 模組方法筆記'>[Perl] 安裝 Perl CPAN 模組方法筆記</a></li>
<li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/1436' rel='bookmark' title='Permanent Link: [Perl] BPS-FlickrFilter'>[Perl] BPS-FlickrFilter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">1. <span style="color: #0000ff;">$_</span> 
<span style="color: #0000ff;">$ARG</span>，常常是一個預設變數 
&nbsp;
2. <span style="color: #0000ff;">@_</span> 
<span style="color: #0000ff;">@ARG</span>，子例程參數表 
&nbsp;
3. <span style="color: #009900;">&#123;</span>row.content<span style="color: #009900;">&#125;</span> 
<span style="color: #0000ff;">$PROGRAM_NAME</span>，本程序的名字 
&nbsp;
4. <span style="color: #0000ff;">@ARGV</span> 
本程序的命令行參數表 
&nbsp;
5. <span style="color: #0000ff;">$&quot;</span> 
<span style="color: #0000ff;">$LIST_SEPARATOR</span>，數組內插到雙引號字符串中時所用的分隔符， 
預設為空格 
&nbsp;
6. <span style="color: #0000ff;">$,</span> 
<span style="color: #0000ff;">$OFS</span>，或<span style="color: #0000ff;">$OUTPUT_FIELD_SEPARATOR</span>，用於<span style="color: #000066;">print</span>的輸出字段分隔符， 
即一個<span style="color: #000066;">print</span>語句中用逗號分隔的部分之間用甚麼分隔，預設為無 
&nbsp;
7. $ 
<span style="color: #0000ff;">$ORS</span>，或<span style="color: #0000ff;">$OUTPUT_RECORD_SEPARATOR</span>，用於<span style="color: #000066;">print</span>的輸出記錄分隔符， 
即一個<span style="color: #000066;">print</span>語句結束時末尾添加甚麼，預設為無 
&nbsp;
8. <span style="color: #0000ff;">$/</span> 
<span style="color: #0000ff;">$RS</span>，或<span style="color: #0000ff;">$INPUT_RECORD_SEPARATOR</span>，輸入記錄分隔符，改變了<span style="color: #000066;">readline</span>， 
<span style="color: #009999;">&lt;FH&gt;</span>和<span style="color: #000066;">chomp</span>對於“行”的看法，預設為換行符 
&nbsp;
9. <span style="color: #0000ff;">$.</span> 
<span style="color: #0000ff;">$NR</span>，或<span style="color: #0000ff;">$INPUT_LINE_NUMBER</span>，最後讀取的“行”號<span style="color: #009900;">&#40;</span>注意行的概念可能 
被<span style="color: #cc66cc;">8</span>所改變<span style="color: #009900;">&#41;</span> 
&nbsp;
10. <span style="color: #0000ff;">$|</span> 
<span style="color: #0000ff;">$AUTOFLUSH</span>，或<span style="color: #0000ff;">$OUTPUT_AUTOFLUSH</span>，輸出緩衝區開關，預設為<span style="color: #cc66cc;">0</span>，即關 
&nbsp;
11. <span style="color: #0000ff;">$$</span> 
<span style="color: #0000ff;">$PID</span>，或<span style="color: #0000ff;">$PROCESS_ID</span>，本腳本的進程號<span style="color: #009900;">&#40;</span>PID<span style="color: #009900;">&#41;</span> 
&nbsp;
12. <span style="color: #0000ff;">$!</span> 
<span style="color: #0000ff;">$ERRNO</span>，或<span style="color: #0000ff;">$OS_ERROR</span>，上一次系統調用錯誤值 
&nbsp;
13. <span style="color: #0000ff;">$@</span> 
<span style="color: #0000ff;">$EVAL_ERROR</span>，上一次<span style="color: #000066;">eval</span>操作錯誤值 
&nbsp;
14. <span style="color: #0000ff;">$^I</span> 
<span style="color: #0000ff;">$INPLACE_EDIT</span>，現場編輯的備份文件擴展名 
&nbsp;
15. <span style="color: #0000ff;">%ENV</span> 
當前環境變數 
&nbsp;
16. 與正則表達式相關的幾個量 
<span style="color: #339933;">|&lt;-</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$`</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;|&lt;-</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$&amp;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;|&lt;-</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;|</span> 
<span style="color: #009966; font-style: italic;">/ ------- mmmmmmmm ++++++++/</span> <span style="color: #339933;">=&gt;</span> 正則表達式<span style="color: #009900;">&#40;</span>注意：空格不代表實際空格<span style="color: #009900;">&#41;</span> 
<span style="color: #339933;">|</span>       <span style="color: #339933;">|</span>匹配部分<span style="color: #339933;">|</span> 
<span style="color: #cc66cc;">0</span>  <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$-</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>      <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$+</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> 
&nbsp;
17. <span style="color: #0000ff;">$^O</span> 
操作系統名稱。 
或者 
<span style="color: #000000; font-weight: bold;">use</span> English<span style="color: #339933;">;</span> 
<span style="color: #000066;">print</span> <span style="color: #0000ff;">$OSNAME</span><span style="color: #339933;">;</span> 
或者 
<span style="color: #000000; font-weight: bold;">use</span> Config<span style="color: #339933;">;</span> 
<span style="color: #000066;">print</span> <span style="color: #0000ff;">$Config</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'osname'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>via <a href="http://www.diybl.com/course/4_webprogram/cgi/perlsl/200862/120679.html">Perl常见特殊变量</a></p>


<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/1449' rel='bookmark' title='Permanent Link: [Perl] 安裝 Perl CPAN 模組方法筆記'>[Perl] 安裝 Perl CPAN 模組方法筆記</a></li>
<li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/1436' rel='bookmark' title='Permanent Link: [Perl] BPS-FlickrFilter'>[Perl] BPS-FlickrFilter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1438/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Perl] BPS-FlickrFilter</title>
		<link>http://blog.lauct.org/archives/1436</link>
		<comments>http://blog.lauct.org/archives/1436#comments</comments>
		<pubDate>Sat, 17 Oct 2009 16:30:38 +0000</pubDate>
		<dc:creator>Lauct</dc:creator>
				<category><![CDATA[電腦＆網路]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.lauct.org/?p=1436</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
這支程式主要是用來練習 Perl 的，功能面倒是其次。 功能： 輸入一 Flickr 照片頁面網址，便會提取出文章標題、頁面連結、圖片網址、作者名稱、標籤，並嵌入CSS和HTML碼中。 原本要用 WWW::Mechanize 模組，但抓取頁面回來的編碼好像會爛掉，只好改用 system call cURL 來抓。另外正規表示式的部份邊翻書邊找用的到的功能。 下一階段目標就是改寫成可以自動發佈到 blogger 上。 Screenshot: （以 http://www.flickr.com/photos/lauct/3701237852/ 為例） ps. 寫的很爛，其實不太好意思放上來 XD FlickrFilter下載： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 [...]


Related posts:<ol><li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
<li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/1438' rel='bookmark' title='Permanent Link: [Perl] 常見特殊變數'>[Perl] 常見特殊變數</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p>這支程式主要是用來練習 Perl 的，功能面倒是其次。</p>
<p><strong>功能：<br />
輸入一 Flickr 照片頁面網址，便會提取出文章標題、頁面連結、圖片網址、作者名稱、標籤，並嵌入CSS和HTML碼中。<br />
</strong><br />
原本要用 WWW::Mechanize 模組，但抓取頁面回來的編碼好像會爛掉，只好改用 system call cURL 來抓。另外正規表示式的部份邊翻書邊找用的到的功能。</p>
<p>下一階段目標就是改寫成可以自動發佈到 blogger 上。</p>
<p>Screenshot:<br />
（以 http://www.flickr.com/photos/lauct/3701237852/ 為例）<br />
<div id="attachment_1444" class="wp-caption aligncenter" style="width: 295px"><a href="http://blog.lauct.org/wp-content/uploads/2009/10/BPS-FlickrFilter-Demo.png"><img src="http://blog.lauct.org/wp-content/uploads/2009/10/BPS-FlickrFilter-Demo-285x300.png" alt="demo" title="BPS-FlickrFilter-Demo" width="285" height="300" class="size-medium wp-image-1444" /></a><p class="wp-caption-text">demo</p></div></p>
<p>ps. 寫的很爛，其實不太好意思放上來 XD<br />
FlickrFilter下載：<a class="downloadlink" href="http://blog.lauct.org/wp-content/plugins/download-monitor/download.php?id=3" title=" downloaded 189 times" >Flickr2bps (189)</a><br />
<span id="more-1436"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env perl</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># flickr.pl</span>
<span style="color: #666666; font-style: italic;"># Created by Chun-Ting Liu on 2009-10-17</span>
&nbsp;
<span style="color: #000066;">require</span> <span style="color: #cc66cc;">5.008008</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#use warnings;</span>
<span style="color: #666666; font-style: italic;">#use strict;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$title</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$imgurl</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$username</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$canonical</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$tag</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$comment</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;請輸入Flickr頁面網址，以利抽取資訊：<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$url</span> <span style="color: #339933;">=</span> <span style="color: #009999;">&lt;STDIN&gt;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">chomp</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$url</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>擷取網頁中...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">system</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;curl $url | head -n 300 &gt; flickr.temp.htm&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;擷取完畢。<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">open</span> FH<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;flickr.temp.htm&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span>  <span style="color: #ff0000;">&quot;開啟檔案失敗: $!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009999;">&lt;FH&gt;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000066;">chomp</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/meta name=&quot;title&quot;/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">s/&lt;meta name=&quot;title&quot; content=&quot;//</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">s/\&quot; \/&gt;//</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #0000ff;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Title:<span style="color: #000099; font-weight: bold;">\n</span>$title<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/link rel=&quot;image_src&quot;/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">s/	&lt;link rel=&quot;image_src&quot; href=&quot;//</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">s/\&quot; \/&gt;//</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">s/_m.jpg/.jpg/</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #0000ff;">$imgurl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Image:<span style="color: #000099; font-weight: bold;">\n</span>$imgurl<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/geo_possessed_username/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">s/var geo_possessed_username = '//</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">s/[;]//</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">s/\\'s\'//</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #0000ff;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;User:<span style="color: #000099; font-weight: bold;">\n</span>$username<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/link rel=&quot;canonical&quot;/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">s/	&lt;link rel=&quot;canonical&quot; href=&quot;//</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">s/\&quot; \/&gt;//</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #0000ff;">$canonical</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;PhotoPageURL:<span style="color: #000099; font-weight: bold;">\n</span>$canonical<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">#&lt;meta name=&quot;description&quot; content=&quot;galileo09&quot;&gt;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/meta name=&quot;description&quot;/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">s/	&lt;meta name=&quot;description&quot; content=&quot;//</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">s/&quot;&gt;//</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #0000ff;">$comment</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Comment:<span style="color: #000099; font-weight: bold;">\n</span>$comment<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">#tag keywords</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/meta name=&quot;keywords&quot;/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">s/	&lt;meta name=&quot;keywords&quot; content=&quot;//</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">s/\&quot;&gt;//</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/photography, digital photography, cameraphones, camera, hobby photography, photo, digital camera, compactflash, smartmedia, cameras, canon, nikon, olympus, fujifilm, video/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #009966; font-style: italic;">s/photography, digital photography, cameraphones, camera, hobby photography, photo, digital camera, compactflash, smartmedia, cameras, canon, nikon, olympus, fujifilm, video//</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/, photography, photos, photo/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #009966; font-style: italic;">s/, photography, photos, photo//</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #0000ff;">$keyword</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>	
<span style="color: #009900;">&#125;</span>
<span style="color: #000066;">close</span> FH<span style="color: #339933;">;</span>
<span style="color: #000066;">system</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;rm flickr.temp.htm&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;HTML code:<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">'&lt;style type=&quot;text/css&quot;&gt;.flickr-photo { }.flickr-frame {	float: center; text-align: center; margin-left: 15px; margin-bottom: 15px; }.flickr-caption { font-size: 0.8em; margin-top: 0px; }&lt;/style&gt;&lt;div class=&quot;flickr-frame&quot;&gt;	&lt;img src=&quot;'</span>.<span style="color: #0000ff;">$imgurl</span>.<span style="color: #ff0000;">'&quot; class=&quot;flickr-photo&quot; style=&quot;border: solid 6px #fff;&quot;/&gt;&lt;br /&gt;&lt;span class=&quot;flickr-caption&quot;&gt;&lt;a href=&quot;'</span>.<span style="color: #0000ff;">$url</span>.<span style="color: #ff0000;">'&quot;&gt;'</span>.<span style="color: #0000ff;">$title</span>.<span style="color: #ff0000;">'&lt;/a&gt;, originally uploaded by '</span>.<span style="color: #0000ff;">$username</span>.<span style="color: #ff0000;">'.&lt;br /&gt;This photo was picked by &lt;a href=&quot;http://beautypapers.blogspot.com/&quot;&gt;beautypapers&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;p class=&quot;flickr-yourcomment&quot;&gt;'</span>.<span style="color: #0000ff;">$comment</span>.<span style="color: #ff0000;">'&lt;/p&gt;'</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Tag:<span style="color: #000099; font-weight: bold;">\n</span>$keyword<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>



<p>Related posts:<ol><li><a href='http://blog.lauct.org/archives/877' rel='bookmark' title='Permanent Link: [Perl] 私人工具箱：flickr2bps'>[Perl] 私人工具箱：flickr2bps</a></li>
<li><a href='http://blog.lauct.org/archives/1439' rel='bookmark' title='Permanent Link: [Perl][轉錄] 實例說明 Perl 特殊變數'>[Perl][轉錄] 實例說明 Perl 特殊變數</a></li>
<li><a href='http://blog.lauct.org/archives/1438' rel='bookmark' title='Permanent Link: [Perl] 常見特殊變數'>[Perl] 常見特殊變數</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.lauct.org/archives/1436/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

