<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>竹北 Perl 推廣組</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/" />
    <link rel="self" type="application/atom+xml" href="http://chupei.pm.org/atom.xml" />
    <id>tag:chupei.pm.org,2010-02-06://1</id>
    <updated>2009-10-22T04:00:48Z</updated>
    <subtitle>竹北 Perl 推廣組</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 5.01</generator>

<entry>
    <title>YAPC::Tiny 第二彈緊急開催</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/10/yapc-tiny-second.html" />
    <id>tag:chupei.pm.org,2009://1.625</id>

    <published>2009-10-22T03:53:28Z</published>
    <updated>2009-10-22T04:00:48Z</updated>

    <summary> 這次特別請到 Perl 社群中最愛橘色的 Leon Brocard 來分享，他目前也是 Perl 5.11.3 版（將於十二月釋出）的負責人。也請所有參加者同時準備一個 5 至 10 分鐘的講題，填寫在報名表中，題材深淺不拘，多多益善。 名額有限，報名從速喔！報名網頁: http://registrano.com/events/yapc-tiny-second...</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
        <category term="Community" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="yapctiny" label="yapctiny" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p><img alt="perl_powered-alpha.png" src="http://chupei.pm.org/images/perl_powered-alpha.png" width="134" height="48" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></p>

<p>這次特別請到 Perl 社群中最愛橘色的 Leon Brocard 來分享，他目前也是 Perl 5.11.3 版（將於十二月釋出）的負責人。也請所有參加者同時準備一個 5 至 10 分鐘的講題，填寫在報名表中，題材深淺不拘，多多益善。</p>

<p>名額有限，報名從速喔！報名網頁: <a href="http://registrano.com/events/yapc-tiny-second">http://registrano.com/events/yapc-tiny-second</a> </p>
]]>
        

    </content>
</entry>

<entry>
    <title>YAPC::Tiny-&gt;first 順利結束</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/09/yapctiny-first-1.html" />
    <id>tag:chupei.pm.org,2009://1.611</id>

    <published>2009-09-06T01:28:13Z</published>
    <updated>2009-09-06T21:51:07Z</updated>

    <summary>感謝大家的參與，YAPC::Tiny-&gt;first 的內容十分的豐富。我們總共有 14 位參與者（包括我本人！） ，果然是最小的 YAPC。 先整理出大家的照片如下： http://www.flickr.com/photos/gugod/sets/72157622129127159/ http://picasaweb.google.com/photolya/YAPCTinyTaichung http://www.flickr.com/photos/42223827@N07/sets/72157622268540074/ 這次我們有許多分享了他們的題目。遠道從以色列來的 nothingmuch 講了新作 Try::Tiny 與 Continuation::Delimited。Ijs 展示了用 Jifty 做的專題「民以食為天」。shelling 分享了他如何延伸他人的模組而讓自已的程式更具可讀性。clkao 再次分享了 Trading with Perl。初次參與 YAPC 活動的 imacat 完整地介紹了他過去的 CPAN 作品，以及「比狐耳更萌的秘密武器」！penk 分享了他的 xPUD 作品。c9s 努力趕出了投影片，分享了非常多影像繪製的 CPAN 模組。ihower 跑來講 Ruby，BlueT 則是很努力做了自我介紹。 這次影片的錄影，在取得大家同意之後，會陸續上傳到Vimeo...</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
        <category term="Community" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="taichung" label="taichung" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="yapctiny" label="yapctiny" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p>感謝大家的參與，YAPC::Tiny->first 的內容十分的豐富。我們總共有 14 位參與者（包括我本人！） ，果然是最小的 YAPC。</p>

<p>先整理出大家的照片如下：</p>

<ul>
<li><a href="http://www.flickr.com/photos/gugod/sets/72157622129127159/">http://www.flickr.com/photos/gugod/sets/72157622129127159/</a></li>
<li><a href="http://picasaweb.google.com/photolya/YAPCTinyTaichung]">http://picasaweb.google.com/photolya/YAPCTinyTaichung</a></li>
<li><a href="http://www.flickr.com/photos/42223827@N07/sets/72157622268540074/">http://www.flickr.com/photos/42223827@N07/sets/72157622268540074/</a></li>
</ul>

<p>這次我們有許多分享了他們的題目。遠道從以色列來的 <a href="http://blog.woobling.org/">nothingmuch</a> 講了新作 Try::Tiny 與 Continuation::Delimited。Ijs 展示了用 Jifty 做的專題「民以食為天」。<a href="http://navyblueshellingford.blogspot.com/">shelling</a> 分享了他如何延伸他人的模組而讓自已的程式更具可讀性。<a href="http://clkao.org/">clkao</a> 再次分享了 Trading with Perl。初次參與 YAPC 活動的 <a href="http://www.imacat.idv.tw/">imacat</a> 完整地介紹了他過去的 CPAN 作品，以及「比狐耳更萌的秘密武器」！<a href="http://penkia.blogspot.com/">penk</a> 分享了他的 xPUD 作品。<a href="http://c9s.blogspot.com/">c9s</a> 努力趕出了投影片，分享了非常多影像繪製的 CPAN 模組。<a href="http://ihower.idv.tw">ihower</a> 跑來講 Ruby，<a href="http://bluet.org/">BlueT</a> 則是很努力做了自我介紹。</p>

<p>這次影片的錄影，在取得大家同意之後，會陸續上傳到<a href="http://vimeo.com/channels/58766">Vimeo 的 YAPC Channel</a>　，請密切注意更新。</p>
]]>
        

    </content>
</entry>

<entry>
    <title>YAPC::Tiny-&gt;first 開始報名</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/08/yapctiny-first.html" />
    <id>tag:chupei.pm.org,2009://1.600</id>

    <published>2009-08-25T01:57:32Z</published>
    <updated>2009-08-25T02:14:09Z</updated>

    <summary>在 OSDC、COSUP、YAPC::NA 以及 YAPC::Asia 都盛大舉辨的今年，我們要先來辨場迷你型的聚會。時間是九月五日星期六 7PM - 9PM、地點在台中市的默契咖啡館（地址：台中市中港路二段60-3號。） 這次聚會的目的主要是希望認識一下在玩 Perl 的各位人士，平時都在關心一些甚麼樣的主題。因此，希望所有人都能夠提供一個 5 分鐘左右的短題目與大家分享。 請有興趣的各位立刻前往報名網頁 http://registrano.com/events/yapc-tiny-first 進行報名。...</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
        <category term="Community" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="tiny" label="tiny" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="yapc" label="yapc" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p>在 <a href="http://osdc.tw/">OSDC</a>、<a href="http://coscup.org/">COSUP</a>、<a href="http://yapc10.org/">YAPC::NA</a> 以及 <a href="http://yapc.asia/">YAPC::Asia</a> 都盛大舉辨的今年，我們要先來辨場迷你型的聚會。時間是九月五日星期六 7PM - 9PM、地點在台中市的<a href="http://www.match-cafe.com/">默契咖啡館</a>（地址：台中市中港路二段60-3號。）</p>

<p>這次聚會的目的主要是希望認識一下在玩 Perl 的各位人士，平時都在關心一些甚麼樣的主題。因此，希望所有人都能夠提供一個 5 分鐘左右的短題目與大家分享。</p>

<p>請有興趣的各位立刻前往報名網頁 <a href="http://registrano.com/events/yapc-tiny-first">http://registrano.com/events/yapc-tiny-first</a> 進行報名。</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Data::Model</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/07/datamodel.html" />
    <id>tag:chupei.pm.org,2009://1.581</id>

    <published>2009-07-06T09:02:55Z</published>
    <updated>2009-07-06T15:23:10Z</updated>

    <summary><![CDATA[Data::Model 是 yappo 最近的新作品，顧名思義，它是個 ORM，就使用風格來說，與之最接近的大概是 DataMapper&nbsp;與 Jifty::DBI和目前大多數的 ORM 系統有別的，Data::Model 嘗試處理多個資料庫來源，它的處理方式是：讓每個 Model 裡面除了定義了資料庫欄位，還指定了資料庫和資料表。...]]></summary>
    <author>
        <name>shelling</name>
        
    </author>
    
    <category term="database" label="database" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="orm" label="ORM" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<a href="http://search.cpan.org/~yappo/Data-Model/">Data::Model</a> 是 <a href="http://blog.yappo.jp/">yappo</a> 最近的新作品，顧名思義，它是個 ORM，就使用風格來說，與之最接近的大概是 <a href="http://www.datamapper.org/">DataMapper</a>&nbsp;與 <a href="http://search.cpan.org/~sartak/Jifty-DBI/">Jifty::DBI</a><div><br /></div><div>和目前大多數的 ORM 系統有別的，Data::Model 嘗試處理多個資料庫來源，它的處理方式是：讓每個 Model 裡面除了定義了資料庫欄位，還指定了資料庫和資料表。</div><div><br /></div>]]>
        <![CDATA[<div>直接來看個簡單的範例：<br /><div><script src="http://gist.github.com/141356.js"></script></div><div>四個檔案中，Posts 和 Users 是 Model，MyApp::DB 則是一些自定義的函式，simple-create-read.pl 則建立一條資料並讀出。</div><div><br /></div><div>Model 中主要就是兩條 DDL，首先先用 <code>base_driver( $driver )</code> 指定映射的資料庫，可用的 driver 可參考 DBI 模組。目前 Data::Model 支援的資料庫則只有 MySQL 和 SQLite 兩樣。當然了，在每個 Model 中重複指定相同的 driver 是很不合乎 perl style 的，我們把他提出到 MyApp::DB 中讓 driver() 處理它。</div><div><br /></div><div>剩下的工作和上述提到的兩個 ORM 就差不多了，install_model() 宣告這個 Model 對應的資料表名稱和 schema。columns() 可說是 Data::Model 最佳的語法糖衣，可以一口氣用預設方式宣告多個欄位，所有的欄位設定方式都寫在 <a href="http://search.cpan.org/~yappo/Data-Model-0.00003/lib/Data/Model/Schema.pm">Data::Model::Schema</a>&nbsp;中。</div><div><br /></div><div>到這裡工作就差不多結束了。噢，因為 Data::Model 還是如此的年輕，所以它還沒有辦法辦到 Auto Migration。在它成長之前，我們姑且自己來作這件事，MyApp::DB::make_schema() 簡單的為我們產生最初的 schema。</div><div><br /></div><div>最後，我們就可以和所有的 ORM 一樣來作 CRUD，如 simple-create-read.pl 最後的幾行。</div><div><br /></div><div>Data::Model 目前的完成度還不高，關於 relation 的部份都還未實做，也還沒有 validator、hook &nbsp;。不過從目前的雛型來看，潛力可期，我們可以期待 yappo 把它完成後的表現。</div><div><br /></div><div>[<a href="http://navyblueshellingford.blogspot.com/2009/07/datamodel.html">English Version</a>]</div><div><br /></div></div>]]>
    </content>
</entry>

<entry>
    <title>YAPC::Asia 2009 開放講者投稿與報名</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/07/yapcasia-2009.html" />
    <id>tag:chupei.pm.org,2009://1.577</id>

    <published>2009-07-03T12:11:44Z</published>
    <updated>2009-07-03T12:25:59Z</updated>

    <summary>原消息在這裡 2009 年的 YAPC::Asia 將在九月10號、11號舉辨，場地將在東京市目黑區大岡山的東京工業大學校區。已於上周開放講者投稿，目前需要的是 20 分鐘或 40 分鐘的演講，七月 17 日將截止。有興趣參與、順便到東京一遊的讀者，敬請密切注意。 除此之外，目前也正在募款中，請參考這裡。也已經有一些有名的 Perl 社群黑客受邀演講，請參考 JPA Blog 自 2006 年舉辨以來，YAPC::Asia 就一直是規模最大的 YAPC。Perl 之父 Larry Wall、狂人 Damian Conway Ruby 之父松本行弘、日本 Ruby 協會會長高橋征義，都曾經參與過這場盛會。 YAPC::Asia - http://yapc.asia/ YAPC::Asia on Twitter - http://twitter.com/yapcasia JPA -...</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
        <category term="Community" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="yapcasia" label="YAPC::Asia" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p>原消息在<a href="http://conferences.yapcasia.org/ya2009/news/426">這裡</a></p>

<p>2009 年的 YAPC::Asia 將在九月10號、11號舉辨，場地將在東京市目黑區大岡山的<a href="http://conferences.yapcasia.org/ya2009/location.html">東京工業大學校區</a>。已於上周開放講者投稿，目前需要的是 20 分鐘或 40 分鐘的演講，七月 17 日將截止。有興趣參與、順便到東京一遊的讀者，敬請密切注意。</p>

<p>除此之外，目前也正在募款中，請參考<a href="http://conferences.yapcasia.org/ya2009/news/429">這裡</a>。也已經有一些有名的 Perl 社群黑客受邀演講，請參考 <a href="http://blog.perlassociation.org/2009/06/yapcasia-tokyo-guest-speakers.html">JPA Blog</a></p>

<p>自 2006 年舉辨以來，YAPC::Asia 就一直是規模最大的 YAPC。Perl 之父 Larry Wall、狂人 Damian Conway Ruby 之父松本行弘、日本 Ruby 協會會長高橋征義，都曾經參與過這場盛會。</p>

<ul>
<li>YAPC::Asia - <a href="http://yapc.asia/">http://yapc.asia/</a></li>
<li>YAPC::Asia on Twitter - <a href="http://twitter.com/yapcasia">http://twitter.com/yapcasia</a></li>
<li>JPA - <a href="http://japan.perlassociation.org/">http://japan.perlassociation.org/</a> <a href="http://blog.perlassociation.org/">http://blog.perlassociation.org/</a></li>
</ul>
]]>
        

    </content>
</entry>

<entry>
    <title>Mini howto: Testing HTTP::Engine-based applications.</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/04/mini-howto-testing-httpengine-based-applications.html" />
    <id>tag:chupei.pm.org,2009://1.551</id>

    <published>2009-04-28T16:46:24Z</published>
    <updated>2009-04-28T16:48:20Z</updated>

    <summary>HTTP::Engine is an abstraction layer over several environments that an web application might be deployed under. For example, CGI, FastCGI, mod_perl, or stand-alone application server. It&#8217;s not a full-featured web-appication framework, but a helpful library when writing applications. This kinds...</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
        <category term="Learning" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="howto" label="howto" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="httpengine" label="HTTP::Engine" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="test" label="test" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="web" label="web" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="webapp" label="webapp" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p><a href="http://search.cpan.org/dist/HTTP-Engine/">HTTP::Engine</a> is an abstraction layer over several environments that an web application might be deployed under. For example, CGI, FastCGI, mod_perl, or stand-alone application server. It&#8217;s not a full-featured web-appication framework, but a helpful library when writing applications. This kinds of idea is especially tasteful when it comes to testing &#8212; because it&#8217;s often cumbersome to fully prepare the environment for testing.</p>

<p><a href="http://gugod.org/2009/04/mini-howto-testing-httpengine-based-applications.html">Read more&#8230;</a></p>
]]>
        

    </content>
</entry>

<entry>
    <title>Poppler 模組</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/04/poppler.html" />
    <id>tag:chupei.pm.org,2009://1.549</id>

    <published>2009-04-28T13:07:37Z</published>
    <updated>2009-04-30T19:20:20Z</updated>

    <summary>最近幾天我寫了一個 Poppler 模組。 將一些 Poppler 主要功能透過 xs 做連結，在裝此模組時，請確定你已經安裝 poppler library , gcc 等等，因為你需要在安裝的時候執行一些編譯動作來將模組編譯並安裝。 Poppler 是一個以 xpdf-3.0 為基礎的 PDF Rendering 函式庫 所以我們可以輕易的利用 poppler 來將 pdf 繪製到 Cairo Context 上頭 (cairo_t*) ， 以下是範例: more progress later......</summary>
    <author>
        <name>c9s</name>
        
    </author>
    
        <category term="CPAN" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="cpan" label="CPAN" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="module" label="Module" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="poppler" label="Poppler" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="xs" label="XS" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[最近幾天我寫了一個 <a href="http://search.cpan.org/dist/Poppler/">Poppler 模組</a>。 將一些 Poppler 主要功能透過 xs 做連結，在裝此模組時，請確定你已經安裝 poppler library , gcc 等等，因為你需要在安裝的時候執行一些編譯動作來將模組編譯並安裝。
<br/>
<br/><a href="http://poppler.freedesktop.org/">Poppler</a> 是一個以 xpdf-3.0 為基礎的 PDF Rendering 函式庫
<br/>
所以我們可以輕易的利用 poppler 來將 pdf 繪製到 Cairo Context 上頭 (cairo_t*) ， 以下是範例:<br/>

<script src="http://gist.github.com/103133.js"></script>
<br/>
more progress later...]]>
        
    </content>
</entry>

<entry>
    <title>SD - peer-to-peer bug tracking system</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/04/sd---peer-to-peer-bug-tracking-system.html" />
    <id>tag:chupei.pm.org,2009://1.548</id>

    <published>2009-04-20T14:21:52Z</published>
    <updated>2009-04-20T18:14:41Z</updated>

    <summary> 今年的 OSDC.TW ， Jesse Vincent 的 topic 為 BestPractical 最近的產品 SD ( peer-to-peer bug tracking system ) 也是 BugTracking 可以 decentralized 、可以 offline working，不直接相依於中央集成的 WebService。 並且有完整的 Shell 可以使用 (再也不用開煩人的 browser 了) 且每個 SD 的 repository 之間都可以 sync ，甚至或是啟動自己的 WebServer。相當的吸引人。...</summary>
    <author>
        <name>c9s</name>
        
    </author>
    
        <category term="CPAN" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="prophet" label="Prophet" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sd" label="SD" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[ 今年的 OSDC.TW ， Jesse Vincent 的 topic 為 BestPractical 最近的產品 SD ( peer-to-peer bug tracking system )<br/><br/>

也是 BugTracking 可以 decentralized 、可以 offline working，不直接相依於中央集成的 WebService。 並且有完整的 Shell 可以使用 (再也不用開煩人的 browser 了) 且每個 SD 的 repository 之間都可以 sync ，甚至或是啟動自己的 WebServer。相當的吸引人。
<br/><br/>
目前 SD 也支援 Trac , Hiveminder 以及 RT。意思就是說 Perl Module Authors 可以使用 SD 來使用 rt.cpan.org。而下一個階段是要做 GoogleCode 服務的整合，也相當歡迎大家幫忙整合 Github 以及 BugZilla 至 SD。
<br/><br/>
SD 使用 Perl 所寫成的 Prophet Database，也相當有趣，Module 的說明如下:
<br/>
<blockquote>Prophet is a distributed database system designed for small to medium scale database applications (currently up to around 50,000 records of
Our early targets include things such as bug tracking.</blockquote>
<br/>
Jesse 的 slide 在這: <a href="http://www.slideshare.net/obrajesse/sd-a-p2p-bug-tracking-system">http://www.slideshare.net/obrajesse/sd-a-p2p-bug-tracking-system
</a><br/>
SD 以及 Prophet 的 source code 可以在 github.com 上頭找到。<br/>
<br/>
本篇文章同步刊登於 <a href="http://c9s.blogspot.com">http://c9s.blogspot.com</a> <br/>]]>
        
    </content>
</entry>

<entry>
    <title>Class::Implant - No &amp;import()</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/04/classimplant---no-import.html" />
    <id>tag:chupei.pm.org,2009://1.546</id>

    <published>2009-04-12T05:39:53Z</published>
    <updated>2009-04-12T08:29:37Z</updated>

    <summary>Class::Implant 是最近和 gugod 寫 Railsish 時，順手實做的模組，可以從 package 外部做 mixin 或是 inheritance，並挑選你想匯入的函式。最初的目的是因為需要為 Controller 引入同名 Helper 的函式，但是又不想讓使用者在 Controller 裡面寫 use XxxHelper ，在 Rails 裡面，這只要在載入類別時進行 XxxController.send(:include, XxxHelper) 就可以辦到，雖然 Perl 裡面也可以寫 eval qq{ package XxxController; use XxxHelper; }; 但是這樣還需要自己定義 XxxHelper::import()，在裡面指定想匯入的函式，實在相當不便。使用 Class::Implant 的話，可以有比較簡單的等價寫法，pacakge main; use...</summary>
    <author>
        <name>shelling</name>
        
    </author>
    
        <category term="CPAN" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<a href="http://github.com/shelling/class-implant/tree/master">Class::Implant</a> 是最近和 <a href="http://gugod.org/">gugod</a> 寫 <a href="github.com/gugod/railsish/tree">Railsish</a> 時，順手實做的模組，可以從 package 外部做 mixin 或是 inheritance，並挑選你想匯入的函式。<div><br /></div><div>最初的目的是因為需要為 Controller 引入同名 Helper 的函式，但是又不想讓使用者在 Controller 裡面寫 use XxxHelper ，在 Rails 裡面，這只要在載入類別時進行<br />
<code><pre>XxxController.send(:include, XxxHelper)</pre></code>

就可以辦到，雖然 Perl 裡面也可以寫 <br />
<code><pre>eval qq{ package XxxController; use XxxHelper; };</pre></code>

但是這樣還需要自己定義 XxxHelper::import()，在裡面指定想匯入的函式，實在相當不便。</div><div><br /></div><div>使用 Class::Implant 的話，可以有比較簡單的等價寫法，</div><div></div><code><pre>pacakge main;
use Class::Implant;
implant "XxxHelper", { into => "XxxController" };</pre></code>如同其字面的意思，把 XxxHelper 中所有的函式都注入了 XxxController。<div><br /></div><div>如果在 main 以外的模組內的話，預設的匯入目標就會變成該模組。也就是說，以上範例可以等價寫成如下：</div>
<code><pre>package XxxController;
use Class::Implant;
implant "XxxHelper";</pre></code>

目前 0.02_01 版的實做還有 match 和 inherit 兩個選項可以使用，{ inherit => 1 } 可以讓匯入的模組出現在匯入目標的 @ISA 中，{ match => pattern } 則是只匯入符合 pattern 的函式。<div><br /></div><div>如：</div><div></div><code><pre>package main;
use Class::Implant;
implant qw(Foo Bar), { into => "Cat", match => qr{h\w+} };
</pre></code>
<br />
<div>代表只把 Foo，Bar 中 h 開頭的函式匯入 Cat 中。</div><div><br /></div>

<div>同時還有 UNIVERSAL::Implant 模組，如同字面意思，這個模組只需要匯入一次，就可以在任何地方這樣寫：</div><br />

<code><pre>Cat->implant qw(Foo Bar), { match => qr{h\w+} } </pre></code><br />

這上一個範例是一樣的效果，也就是由呼叫類別 Cat 指定了 { into => "Cat" }。]]>
        
    </content>
</entry>

<entry>
    <title>Parrot 1.0.0 &quot;Haru Tatsu&quot; Released!</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/03/parrot-100-haru-tatsu-released.html" />
    <id>tag:chupei.pm.org,2009://1.542</id>

    <published>2009-03-19T13:33:23Z</published>
    <updated>2009-03-21T02:59:38Z</updated>

    <summary>Perl 6 實做品之一的 Parrot 已於 2009/3/17 釋出 1.0.0 版本，消息發佈於 http://www.parrot.org/news/2009/Parrot-1.0.0。***allison 著， shelling 譯代表 Parrot 開發團隊，我很榮幸在此發佈 Parrot 1.0.0 &quot;Haru Tatsu&quot;。Parrot 是一個支援多種動態語言的虛擬機 (virtual machine)。Parrot 1.0.0 可以從 Parrot 的 FTP 站或下載引導頁來下載，對於想要在 Parrot 上開發或是協助開發 Parrot 的人，我們建議使用 Subversion 從我們的源碼庫取得最新的原始碼。Parrot 1.0.0 新特色如下： - 文件 + 給使用者的新版例外處理文件...</summary>
    <author>
        <name>shelling</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Perl 6 實做品之一的 Parrot 已於 2009/3/17 釋出 1.0.0 版本，<span class="Apple-style-span" style="color: rgb(51, 51, 51);">消息發佈於</span><span class="Apple-style-span" style="border-collapse: separate; color: rgb(51, 51, 51); font-family: arial; line-height: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: collapse; font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "> </span><a href="http://www.parrot.org/news/2009/Parrot-1.0.0" style="text-decoration: underline; ">http://www.parrot.org/news/2009/Parrot-1.0.0</a>。<a href="http://www.parrot.org/news/2009/Parrot-1.0.0" style="text-decoration: underline; "></a></span></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br /></span></div><div style="text-align: center;"><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">***</span></div><div style="text-align: center;"><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">allison 著， <a href="http://navyblueshellingford.blogspot.com/">shelling</a> 譯</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br /></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">代表 Parrot 開發團隊，我很榮幸在此發佈 Parrot 1.0.0 "Haru Tatsu"。Parrot 是一個支援多種動態語言的虛擬機 (virtual machine)。</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br /></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">Parrot 1.0.0 可以從 <a href="ftp://ftp.parrot.org/pub/parrot/releases/stable/1.0.0/">Parrot 的 FTP 站</a>或<a href="http://parrot.org/download">下載引導頁</a>來下載，對於想要在 Parrot 上開發或是協助開發 Parrot 的人，我們建議使用 <a href="http://subversion.tigris.org/">Subversion </a>從我們的<a href="https://svn.parrot.org/parrot/trunk/">源碼庫</a>取得最新的原始碼。</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br /></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">Parrot 1.0.0 新特色如下：</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(29, 45, 69); font-family: 'Trebuchet MS'; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br /></span></div><div></div>
<pre><code>- 文件
  + 給使用者的新版例外處理文件
  + 更新 Parrot Book 的第四和第五章
  + 改善和擴充自動生成的文件，如 <a href="http://docs.parrot.org/">http://docs.parrot.org/</a> 所示
  + 新增 CHM 格式的 Help 文件
  + 修正和改善許多部份
- 語言
  + Pynie
    - 獨立出來置於 <a href="http://pynie.googlecode.com/">http://pynie.googlecode.com/</a>
  + Cardinal
    - 獨立出來置於 <a href="http://github.com/cardinal">http://github.com/cardinal</a>
  + APL
    - 獨立出來置於 <a href="http://paraplegic.googlecode.com/">http://paraplegic.googlecode.com/</a>
  + ABC, Squaak 和 Befunge 移到 examples/
  + 剩下的語言移至 <a href="https://svn.parrot.org/languages/">https://svn.parrot.org/languages/</a>
- 工具
  + 支援從已安裝的 Parrot 進行 language builds 
  + 擴充給新語言使用的 language shell generator
  + 新增 'parrotbug' 工具集對 Trac 的介面
- 準廢棄
  + 移除準廢棄的 Tqueue 和 Closure PMCs
  + String, Key, NCI, LexPad, Sub, Contnuation,
    RetContinuation, ExceptionHandler, ParrotLibrary,
    ParrotInterpreter, ParrotThread, ParrotRunningThread,
    Rational, FixedPMCArray, ResizablePMCArray, and GDBMHash
    PMCs now use declared attributes (ATTR), in place of the
    deprecated UnionVal .
</code></pre>
<div style="text-align: center;">***</div>]]>
        
    </content>
</entry>

<entry>
    <title>REPL in Perl</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/03/repl-in-perl.html" />
    <id>tag:chupei.pm.org,2009://1.541</id>

    <published>2009-03-14T10:49:17Z</published>
    <updated>2009-03-14T11:51:27Z</updated>

    <summary>Read-Evaluate-Print Loop 在現代語言中非常常見，諸如 Scheme， Haskell， Ruby， 與 Python 都有內建，實際工作時是非常實用的工具，Perl 6 也即將內建 REPL Shell，Perl 5 則沒有。這幾天偶然想在 Perl 中使用 REPL，搜尋了一下，在 use.perl.org 得到 2007 年發表的這篇文章，介紹了四個以 Perl 5 實做的 REPL Shell，翻譯如下。...</summary>
    <author>
        <name>shelling</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[Read-Evaluate-Print Loop 在現代語言中非常常見，諸如 Scheme， Haskell， Ruby， 與 Python 都有內建，實際工作時是非常實用的工具，Perl 6 也即將內建 REPL Shell，Perl 5 則沒有。<div><br /></div><div>這幾天偶然想在 Perl 中使用 REPL，搜尋了一下，在 <a href="http://use.perl.org/">use.perl.org</a> 得到 2007 年發表的<a href="http://use.perl.org/articles/07/08/30/1729255.shtml">這篇文章</a>，介紹了四個以 Perl 5 實做的 REPL Shell，翻譯如下。<div><div><br /></div></div></div>]]>
        <![CDATA[<div><div style="text-align: center; "><div style="text-align: auto;">***</div><div style="text-align: auto;"><a href="http://use.perl.org/~ferreira/journal/">ferrerira</a> 著</div></div><div><br /></div><div>我今天在 CPAN Recent Uploads 看到 perlconsole-0.3（譯著：目前為 0.4 ）發佈，讓我回想起這東西。幾個月前你可能花費不少時間搜尋 Perl 的 REPL Shell，現在你有許多選擇了。你可以從下列選項中挑選一個使用。</div><div><br /></div><div><ul><li><a href="http://search.cpan.org/dist/Shell-Perl">Shell::Perl</a></li><li><a href="http://search.cpan.org/dist/Devel-Perl">Devel::REPL</a></li><li><a href="http://search.cpan.org/dist/App-Repl">App::REPL</a></li><li><a href="http://search.cpan.org/dist/perlconsole">perlconsole</a></li></ul></div><div><br /></div><div>(當然，還有很多選項，但我不記得連結了。可能還有一些我沒聽過的。)</div><div><br /></div><div>有些強者也寫了相關文章。</div><div><br /></div><div><ul><li>Matt Trout 寫的〈<a href="http://chainsawblues.vox.com/library/post/a-perl-read-excute-print-loop-repl.html">寫一個 Perl read-eval-print (REPL) - part 1</a>〉和許多 blog 文章</li><li>chromatic 寫的〈<a href="http://www.oreillynet.com/onlamp/blog/2007/04/writing_a_modern_perl_repl.html">寫一個現代 Perl REPL</a>〉</li></ul></div><div><br /></div><div>有時，我也看到一些談論這類工具的評論在這裡出現（如：tokuhirom 所寫的〈<a href="http://use.perl.org/~tokuhirom/journal/33817">我寫了 Test::ShellPerl</a>〉）</div><div><br /></div><div>抱歉的是，最近這幾個月我有點疏於關心 Shell::Perl (pirl)。不過它現在又恢復生氣了，因為我發現不少人在使用它。</div><div><br /></div><div>有什麼想法嗎？請分享出來吧。</div><div><br /></div><div style="text-align: center;">***</div></div>]]>
    </content>
</entry>

<entry>
    <title>算算一年中有幾個十三號星期五</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/03/post.html" />
    <id>tag:chupei.pm.org,2009://1.540</id>

    <published>2009-03-12T17:12:30Z</published>
    <updated>2009-03-12T17:30:29Z</updated>

    <summary>2009 年由於二月、三月都是 13 號星期五，所以還搞了部電影出來。不過讓我比較好奇的是：一年之中最多會有幾個十三號星期五？ 大致上翻了一下月曆發現好像都不會超過三個。於是寫了個程式來測試一下： 輸出大約是這樣 1 black Friday in the year 2000: 2000-10-13 2 black Fridays in the year 2001: 2001-4-13 2001-7-13 2 black Fridays in the year 2002: 2002-9-13 2002-12-13 1 black Friday in the year 2003: 2003-6-13...</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
    <category term="datetime" label="datetime" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="friday" label="Friday" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gist" label="gist" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="pluralize" label="pluralize" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="research" label="research" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p>2009 年由於二月、三月都是 13 號星期五，所以還搞了部電影出來。不過讓我比較好奇的是：一年之中最多會有幾個十三號星期五？</p>

<p>大致上翻了一下月曆發現好像都不會超過三個。於是寫了個程式來測試一下：</p>

<script src="http://gist.github.com/78165.js"></script>

<p>輸出大約是這樣</p>

<pre>
1 black Friday in the year 2000: 2000-10-13
2 black Fridays in the year 2001: 2001-4-13 2001-7-13
2 black Fridays in the year 2002: 2002-9-13 2002-12-13
1 black Friday in the year 2003: 2003-6-13
2 black Fridays in the year 2004: 2004-2-13 2004-8-13
1 black Friday in the year 2005: 2005-5-13
2 black Fridays in the year 2006: 2006-1-13 2006-10-13
2 black Fridays in the year 2007: 2007-4-13 2007-7-13
1 black Friday in the year 2008: 2008-6-13
3 black Fridays in the year 2009: 2009-2-13 2009-3-13 2009-11-13
1 black Friday in the year 2010: 2010-8-13
1 black Friday in the year 2011: 2011-5-13
3 black Fridays in the year 2012: 2012-1-13 2012-4-13 2012-7-13
2 black Fridays in the year 2013: 2013-9-13 2013-12-13
1 black Friday in the year 2014: 2014-6-13
3 black Fridays in the year 2015: 2015-2-13 2015-3-13 2015-11-13
1 black Friday in the year 2016: 2016-5-13
2 black Fridays in the year 2017: 2017-1-13 2017-10-13
2 black Fridays in the year 2018: 2018-4-13 2018-7-13
2 black Fridays in the year 2019: 2019-9-13 2019-12-13
2 black Fridays in the year 2020: 2020-3-13 2020-11-13
1 black Friday in the year 2021: 2021-8-13
1 black Friday in the year 2022: 2022-5-13
.... (略)
</pre>

<p>跑完這個程式發現未來一萬年之中都不會有超過三個黑色星期五的年份。似乎三個就是上限了。這感覺起來是個不錯的數學證明題目。</p>

<p>而其中有三個黑色星期五的年份，佔了約整體的七分之一。換句話說每七年中就有一年會是三個星色星期五。但從 2009 年開始算的話，未來七年當中的 2012 跟 2015 也都是有三個黑色星期五的年份。比例還真是高。</p>

<p>另一個有趣的事實則是：每年都至少會有一個十三號星期五。</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Mac OS X Security Update 2009-001 可能會破壞你的 Perl (CPAN)</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/02/mac-os-x-security-update-2009-001-perl-cpan.html" />
    <id>tag:chupei.pm.org,2009://1.535</id>

    <published>2009-02-15T00:26:51Z</published>
    <updated>2009-02-15T00:46:42Z</updated>

    <summary>miyagawa 、lopnor、typester 都指出，剛剛釋出的 Mac OSX Security Update 2009-001 可能會把你機器上的 Perl / cpan 搞壞了。如果你平常工作的 Perl 環境是： Mac OSX 10.5 Leopard使用 Mac 內附的 Perl曾經利用 CPAN 升級過幾個核心模組 使用 MacPorts 的 Perl 者，或從未使用 cpan 更新模組的者，則無需擔心。 可以使用以下這一行指令來測試是是否正常 /usr/bin/perl -MIO -le &apos;print &quot;ok&quot;&apos; 如果你看見它印出 &#8220;ok&#8221; 則沒問題，若看見像這樣的訊息，就表示壞了：...</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
        <category term="CPAN" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="breakage" label="breakage" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="cpan" label="cpan" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mac" label="mac" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="security" label="security" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="update" label="update" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p><a href="http://bulknews.typepad.com/blog/2009/02/mac-os-x-security-update-2009001-breaks-perl-cpan.html">miyagawa</a> 、<a href="http://journal.soffritto.org/entry/334">lopnor</a>、<a href="http://unknownplace.org/memo/">typester</a> 都指出，剛剛釋出的 <a href="http://support.apple.com/kb/HT3438">Mac OSX Security Update 2009-001</a> 可能會把你機器上的 Perl / cpan 搞壞了。如果你平常工作的 Perl 環境是：</p>

<ul><li>Mac OSX 10.5 Leopard</li><li>使用 Mac 內附的 Perl</li><li>曾經利用 CPAN 升級過幾個核心模組</li></ul>

<p>使用 MacPorts 的 Perl 者，或從未使用 cpan 更新模組的者，則無需擔心。</p>

<p>可以使用以下這一行指令來測試是是否正常</p>

<pre>
/usr/bin/perl -MIO -le 'print "ok"'
</pre>

<p>如果你看見它印出 &#8220;ok&#8221; 則沒問題，若看見像這樣的訊息，就表示壞了：</p>

<pre>
IO object version 1.22 does not match bootstrap parameter 1.23
at /System/Library/Perl/5.8.8/darwin-thread-multi-2level/XSLoader.pm
line 94.

Compilation failed in require.
BEGIN failed--compilation aborted.
</pre>

<p>這段訊息出現的原因，乃是因為核心模組 IO.bundle 1.22 版被包含在 Mac OSX Security Update 2009-001 當中。只要你曾經升級 IO.pm 到 1.23 版，那就會出現如上的「版本不符」的死亡錯誤訊息。</p>

<p>解決辨法是再裝一次 1.23 版的 IO 模組。 </p>

<p>但糟的是，由於它是 IO 模組，所以你無法使用一般的 cpan 指令（因為一執行 cpan 就要載入 IO 模組），所以只能手動下載 <a href="http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.2301.tar.gz">IO-1.2301 tarball</a> ，解開之後執行 <code>perl Makefile.PL; make; make install</code></p>

<p>而 <code>IO-1.2301</code> 早在 2006 年就已經釋出了，是個非常穩定的版本，Apple 你為什麼要故意散佈一個 1.22 版的 IO.bundle 呢？</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Sub::Alias - 替函式取別名</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2009/01/subalias--.html" />
    <id>tag:chupei.pm.org,2009://1.528</id>

    <published>2009-01-09T13:40:16Z</published>
    <updated>2009-01-09T13:51:47Z</updated>

    <summary>最近在寫的 Sub::Alias 模組能夠很便利地替函式取別名： use Sub::Alias; sub name { &quot;...&quot; } alias get_name =&gt; &apos;name&apos;;...</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
        <category term="CPAN" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="develbeginlift" label="devel::beginlift" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="develdeclare" label="devel::declare" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="subalias" label="sub::alias" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p>最近在寫的 <a href="http://search.cpan.org/dist/Sub-Alias/">Sub::Alias</a> 模組能夠很便利地替函式取別名：</p>

<pre>
use Sub::Alias;

sub name { "..." }

alias get_name => 'name';
</pre>
]]>
        <![CDATA[<p>比較熟習 Perl 的人大概可以看出來其實這就是：</p>

<pre>
*get_name = \&name;
</pre>

<p>但是好懂多了。</p>

<p>剛剛釋出了 0.03 版，增加了對 runtime 的支援：</p>

<pre>
sub alias_another_sub {
    my $new_name = shift;

    alias $new_name => 'another_sub';     
}

alias_another_sub_to( "hey" );
</pre>

<p>如果用 Perl 原本的做法，這相當於：</p>

<pre>
no strict;
*{"$new_name"} = \&another_sub;
</pre>

<p>是的，在執行時期操弄 symbol table，就必需要關掉 strict 才行。</p>

<p>這個模組只算是個小幫手，不過實做它卻出乎意料地有點難度，需要使用 <a href="http://search.cpan.org/dist/Devel-BeginLift/">Devel::BeginLift</a> 與 <a href="http://search.cpan.org/dist/Devel-Declare/">Devel::Declare</a> 兩個模組，在編輯時期操弄 symbol table，甚至是注入新的原始碼。</p>
]]>
    </content>
</entry>

<entry>
    <title>Binding.pm implemented</title>
    <link rel="alternate" type="text/html" href="http://chupei.pm.org/2008/12/bindingpm-implemented.html" />
    <id>tag:chupei.pm.org,2008://1.525</id>

    <published>2008-12-28T20:34:00Z</published>
    <updated>2008-12-28T21:00:51Z</updated>

    <summary>So I had 3 Espresso in a row this afternoon. The coffee bean was brought from this little Handan (meaning: lotus bud) Cafe. It was a little bit out-dated, with some noise in the taste, but it still awesomely sour....</summary>
    <author>
        <name>gugod</name>
        
    </author>
    
        <category term="CPAN" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="binding" label="binding" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="cpan" label="cpan" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="espresso" label="espresso" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="lotusbud" label="lotus bud" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="of_caller" label="of_caller" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="tcl" label="tcl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="uplevel" label="uplevel" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://chupei.pm.org/">
        <![CDATA[<p>So I had 3 Espresso in a row this afternoon. The coffee bean was brought from this little Handan (meaning: lotus bud) Cafe. It was a little bit out-dated, with some noise in the taste, but it still awesomely sour.</p>

<p>Conclusion: dynamic languages are fun.</p>

<p>I need to solved this problem when I was implementing Markapl:</p>

<p>How do I eval this code:</p>

<pre><code>eval 'my @attr = ($x, $y)';
</code></pre>

<p>With <code>$x</code> and <code>$y</code> coming from my caller scope ?</p>
]]>
        <![CDATA[<p>In other words, how do I implement the <code>caller_eval</code> function in this code:</p>

<pre>
sub x_add_one {
    caller_eval '$x + 1';
}

sub ans {
    my $x = 41;
    x_add_one;
}

print ans; #42
</pre>

<p>It was more generic for Markapl, but the <code>caller_eval</code> can solve the problem in Markapl. Today, I re-factor that piece of work into a standalone moulde, Binding.pm</p>

<p>You can see the solution to this problem in other dynamic languages. The <a href="http://www.astro.princeton.edu/~rhl/Tcl-Tk_docs/tcl/uplevel.n.html">uplevel</a> function in Tcl language and <a href="http://extensions.rubyforge.org/rdoc/classes/Binding.html#M000022">Binding.of_caller</a> method in Ruby (extension.)</p>

<p>I give it the same name as in Ruby. Binding. Here&#8217;s a brief synopsis of how to use it:</p>

<pre>
my $binding = Binding->of_caller;
$binding->eval('$x + 1');
</pre>

<p>The code examples given in here are all special instances, since the evaled code actually specified the variable <code>$x</code> to use by its name. In the implementation of Markapl, the names of variables is also stored in a variable, so I needed a generic solution. (ps. That part was lately re-implemented and does not require this eval now.)</p>

<p>The implementation is to use <code>peek_my</code> function from PadWalker with <code>pp</code> from Data::Dump to clone caller&#8217;s lexical variables. It&#8217;s not a perfect way but it&#8217;s a beginning.</p>

<p>These are not implemented, but some good targets to try:</p>

<ul>
<li>Binding->of_package</li>
<li>Binding->of_sub</li>
<li>Binding->local</li>
</ul>

<p>It can be easily seen that these are quite challenging and probably impractical. More like an experimental and research-kind of work.</p>

<p>BTW, then I can just use this in my <a href="http://search.cpano.rg/dist/Rubyish/">Rubyish.pm</a> too.</p>

<p>This piece of work is already uploaded to CPAN: <a href="http://search.cpan.org/dist/Binding/">http://search.cpan.org/dist/Binding/</a>, while its source code repository is hosted on Github: <a href="http://github.com/gugod/binding/tree/master">http://github.com/gugod/binding/tree/master</a>. Please take a look and give me some feedback.</p>
]]>
    </content>
</entry>

</feed>
