<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>pid</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/pid/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/pid/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/pid//89</id>
    <updated>2011-02-03T13:02:26Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>The Beauty of a Perl Quicksort</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/pid/2011/02/the-beauty-of-a-perl-quicksort.html" />
    <id>tag:blogs.perl.org,2011:/users/pid//89.1417</id>

    <published>2011-02-03T07:15:25Z</published>
    <updated>2011-02-03T13:02:26Z</updated>

    <summary>Yet Another Misleading Title. :) err...I have to say, (I can&apos;t remember the exact time I met this version of quicksort), ever since the Haskell version was born, there were (and still are) various implementations available in various languages. This...</summary>
    <author>
        <name>pid</name>
        
    </author>
    
    <category term="lisp" label="Lisp" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="quicksort" label="Quicksort" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/pid/">
        <![CDATA[<p>Yet Another Misleading Title. :)</p>

<p>err...I have to say, (I can't remember the exact time I met this version of quicksort), ever since the Haskell version was born, there were (and still are) various implementations available in various languages. This version of quicksort is a very nature "translation" of what the algorithm is:</p>

<pre><code>function quicksort(list) {
    select a pivot;
    return (quicksort([x|x&lt;pivot]), pivot, quicksort([x|x&gt;pivot]));
}</code></pre>

<p>Today, I met this version again in <a href="http://www.reddit.com/r/lisp/comments/fe69b/swisspignet_the_beauty_of_a_lisp_quicksort/">here</a> <span style="color: grey;">(reddit.com)</span>. For convenience, let me repost the Lisp code:</p>

<pre><code>(defun quicksort (lis) (if (null lis) nil
  (let* ((x (car lis)) (r (cdr lis)) (fn (lambda (a) (< a x))))
    (append (quicksort (remove-if-not fn r)) (list x)
      (quicksort (remove-if fn r))))))</code></pre>

<p>I wonder if I could reinvent(port, steal, rob, grab...whatever) it to Perl...and this is what I did:</p>

<pre><code class="prettyprint">sub quicksort {
    return () if @_ == 0;

<p>    my ($head, @tail) = @_;<br />
    my $less_than_head = sub { $_[0] < $head };</p>

<p>    return quicksort( grep {   $less_than_head->($_)   }  @tail ), <br />
           $head,<br />
           quicksort( grep { not $less_than_head->($_) }  @tail );<br />
}</code></pre></p>

<p>...and Rosetta Code can always bring me <a href="http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Perl">a "better(more Perlish)" one</a>:</p>

<pre><code class="prettyprint">sub quicksort {
	@_ &lt;= 1 ? @_ : do {
		my $pivot = pop;
		quicksort( grep {$_ <= $pivot} @_ ), 
		$pivot, 
		quicksort( grep {$_ >  $pivot} @_ )
	}
}</code></pre>

<p>Don't you think my Perl code is "beautiful"(and more like plain English) too?</p>

<p>IMHO, the beauty comes out of the way it is implemented, not the language we use. "Perl is ugly, I want you to create beautiful things in Perl", we all agree with that. ;-)</p>]]>
        
    </content>
</entry>

<entry>
    <title>Yet Another Post on &quot;Pascal Triangle&quot;</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/pid/2010/08/yet-another-post-on-pascal-triangle.html" />
    <id>tag:blogs.perl.org,2010:/users/pid//89.956</id>

    <published>2010-08-29T02:55:06Z</published>
    <updated>2010-08-29T05:23:18Z</updated>

    <summary><![CDATA[又名：如何用一行Perl 6打印杨辉三角前n行。 从此时开始到目前为止，网上至少有三篇关于如何用Perl 6打印杨辉三角的文章：这里(TimToady), 这里(Moritz), 和 这里(Masak)。 "There's more than one way to do it."，好吧，我也来写一个，下面这行代码打印杨辉三角的前10行： ([1], -> @p { 0, @p Z+ @p, 0 } ... *).[^10].perl.say; （......多少都有些抄袭的嫌疑，其实就是直接拼成一行了，不是吗？:)） 简单解释下： "infix:&lt;...&gt;"称为"Series Operator"(S03)，相当于把对一个块的求值结果push到最前面的List里面，直到满足右边的条件为止。比如： (1, {$_ + 1} ... 5).perl.say; → (1, 2,...]]></summary>
    <author>
        <name>pid</name>
        
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/pid/">
        <![CDATA[<p>又名：如何用一行Perl 6打印杨辉三角前n行。</p>

<p>从<a href="http://irclog.perlgeek.de/perl6/2010-08-25#i_2746334">此时</a>开始到目前为止，网上至少有三篇关于如何用Perl 6打印<a href="http://zh.wikipedia.org/zh/杨辉三角形">杨辉三角</a>的文章：<a href="http://rosettacode.org/wiki/Pascal's_triangle#Perl_6">这里</a>(TimToady), <a href="http://www.perlgeek.de/blog-en/perl-6/pascal-triangle.html">这里</a>(Moritz), 和 <a href="http://use.perl.org/~masak/journal/40516">这里</a>(Masak)。</p>

<p>"There's more than one way to do it."，好吧，我也来写一个，下面这行代码打印杨辉三角的前10行：</p>

<pre><code class="prettyprint">([1], -> @p { 0, @p Z+ @p, 0 } ... *).[^10].perl.say;
</code></pre>
（......多少都有些抄袭的嫌疑，其实就是直接拼成一行了，不是吗？:)）

<p><br />
简单解释下：</p>

<p>"<code>infix:&lt;...&gt;</code>"称为"Series Operator"(<a href="http://perlcabal.org/syn/S03.html#List_infix_precedence">S03</a>)，相当于把对一个块的求值结果<code>push</code>到最前面的<code>List</code>里面，直到满足右边的条件为止。比如：</p>

<pre><code class="prettyprint">(1, {$_ + 1} ... 5).perl.say;
→ (1, 2, 3, 4, 5)
</code></pre>

<p><br />
"<code>*</code>"在这里是一个被叫做"<code>Whatever</code>"(<a href="http://perlcabal.org/syn/S02.html">S02</a>)的东西，在这里起构造惰性求值列表的作用。<br /><br />
中间自"<code>-&gt; { }</code>"起，是一个由"<code>-&gt;</code>"(<a href="http://perlcabal.org/syn/S06.html#%22Pointy_blocks%22">S06</a>)构造的轻量型匿名函数块，即要应用（"apply"）的部分。类似于Perl 5中"<code>map BLOCK LIST</code>"的"<code>BLOCK</code>"。同时，"<code>Z+</code> Operator"(<a href="http://perlcabal.org/syn/S03.html#Zip_operators">S03</a>)将两边列表结对相加。关于此操作符的用法举例如下：</p>

<pre><code class="prettyprint">(1, 2, 3 Z+ 4, 5, 6).perl.say;
→ (5, 7, 9)
</code></pre>

<p>额外一提："<code>Z+</code>"属于"Zip Operator"系列，类似的还有"<code>Z~</code>"，可以用它实现成对字符串拼接：</p>

<pre><code class="prettyprint">(1, 2, 3 Z~ 4, 5, 6).perl.say;
→ ("14", "25", "36")
</code></pre>

<p>现在，把代码中的"<code>10</code>"改成需要打印的行数，就可以实现"用一行Perl 6打印杨辉三角前n行"了。:)</p>

<p>顺便说下，现在想试试Perl 6的话用不着安装，直接<a href="http://try.rakudo.org/">Try Rakudo</a>！</p>]]>
        
    </content>
</entry>

<entry>
    <title>公告：Rakudo Star - 一个可用、实用的Perl 6早期发行版</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/pid/2010/08/rakudo-star---perl-6.html" />
    <id>tag:blogs.perl.org,2010:/users/pid//89.831</id>

    <published>2010-08-05T09:39:18Z</published>
    <updated>2010-08-05T09:48:24Z</updated>

    <summary>本文为个人翻译，仅作参考之用，一切以原文为准。 原文链接： Announce: Rakudo Star - a useful, usable, &quot;early adopter&quot; distribution of Perl 6 作者：pmichaud 我谨代表Rakudo以及Perl 6开发团队高兴地向各位宣布Rakudo Star ── 一个可用、实用Perl 6早期发行版已于2010年7月发布。该发行版的tar源码包可以从 http://github.com/rakudo/star/downloads 下载。 Rakudo Star 着重打造Perl 6的一个尝鲜版本。我们知道它仍然包含缺陷，也慢于其应有的速度,且未实现Perl 6语言标准中的部分高级特性，但是 Rakudo Perl 6 之现状恰说明或为其开发应用程序或将其作为一门新型编程语言来探究的可行性(和乐趣)。一系列的&quot;Star&quot;发行版将力使Perl 6更加接近程序员，扩展Perl 6代码基础，以及赢得最终用户对Perl 6语言本身及其Rakudo实现的额外反馈。 在Perl6的世界里，我们将语言(&quot;Perl 6&quot;)和语言的特定实现(例如&quot;Rakudo Perl&quot;)加以区分，&quot;Rakudo Star&quot;发行版由Rakudo...</summary>
    <author>
        <name>pid</name>
        
    </author>
    
    <category term="annoncement" label="annoncement" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl6" label="Perl 6" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rakudo" label="Rakudo" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/pid/">
        <![CDATA[<p><strong>本文为个人翻译，仅作参考之用，一切以原文为准。</strong></p>

<p>原文链接： <a href="http://rakudo.org/announce/rakudo-star/2010.07">Announce: Rakudo Star - a useful, usable, "early adopter" distribution of Perl 6</a></p>

<p>作者：pmichaud</p>

<p>我谨代表Rakudo以及Perl 6开发团队高兴地向各位宣布Rakudo Star ── 一个可用、实用Perl 6早期发行版已于2010年7月发布。该发行版的tar源码包可以从 http://github.com/rakudo/star/downloads 下载。</p>

<p>Rakudo Star 着重打造Perl 6的一个尝鲜版本。我们知道它仍然包含缺陷，也慢于其应有的速度,且未实现Perl 6语言标准中的部分高级特性，但是 Rakudo Perl 6 之现状恰说明或为其开发应用程序或将其作为一门新型编程语言来探究的可行性(和乐趣)。一系列的"Star"发行版将力使Perl 6更加接近程序员，扩展Perl 6代码基础，以及赢得最终用户对Perl 6语言本身及其Rakudo实现的额外反馈。</p>

<p>在Perl6的世界里，我们将语言("Perl 6")和语言的特定实现(例如"Rakudo Perl")加以区分，"Rakudo Star"发行版由Rakudo Perl 6编译器的#31发行版[1]，Parrot虚拟机2.6.0版[2]，各式模块，文档，以及其他从Perl 6社区收集起来的资源所共同构成。我们拟将Rakudo Star按月发布，同时也将不时地发布反映重大变更及缺陷修复的特别版本。</p>

<p>本Rakudo Star发行版所含部分Perl 6新酷特性：</p>

<ul>
	<li> Perl 6语法（"grammar"）和正则表达式（"regexes"）</li>
	<li> 正式参数列表和签名（"signatures"）</li>
	<li> 元操作符</li>
	<li> 进阶类型（"gradual typing"）</li>
	<li> 强大的对象模型，包括角色（"roles"）和对象（"objects"）</li>
	<li> 惰性列表求值（"lazy list evaluation"）</li>
	<li> 多重分派（"multiple dispatch"）</li>
	<li> 智能匹配</li>
	<li> 边界（"junctions"）和自动线程化（"autothreading"）</li>
	<li> 操作符重载（目前所支持的形式有限）</li>
	<li> 内省（"introspection"）</li>
	<li> 柯里化（"currying"）</li>
	<li> 丰富的内置操作符、函数和类型</li>
	<li> 互动的"读取-求值-打印"循环（"read-evaluation-print loop, REPL"）</li>
	<li> 代码点（"codepoint"）级的Unicode支持</li>
	<li> 可恢复异常（"resumable exceptions"）</li>
</ul>

<p>本Rakudo Star发行版无法正确处理部分Perl 6关键特性，将在后续版本中修正。这样我们便不会将Rakudo Star作为"Perl 6.0.0"或"1.0"版。上述特性包括：</p>

<ul>
	<li> 嵌套包定义</li>
	<li> 二进制对象，原生类型，pack和unpack</li>
	<li> 指定类型的数组</li>
	<li> 宏</li>
	<li> state 变量</li>
	<li> 线程和并发</li>
	<li> 非代码点级别的Unicode字符串</li>
	<li> 前、后约束，以及其他phasers</li>
	<li> REPL中readline对Unicode输入的支持</li>
	<li> 正则表达式字符范围<[...]>中的反斜杠转义</li>
	<li> 非阻塞I/O</li>
	<li> Synopsis 9的大部分</li>
	<li> perl6doc和POD工具</li>
</ul>

<p>我们于各处着手，使得Rakudo足够智能地告知程序员某特性尚未实现，但始终有所疏漏。欢迎提交有关功能缺失或实现不完整的缺陷报告。</p>

<p>有关Perl 6更多信息的链接，敬请查阅http://perl6.org，包括文档、程序示例、教程、参考材料、标准文档，及其他支持资料。</p>

<p>Rakudo Star 捆绑了若干模块，本发行版所含的模块列举如下：</p>

<ul>
	<li> Blizkost - 启用一些在Rakudo Perl 6中用到的Perl 5模块</li>
	<li> MiniDBI  - 一个Rakudo Perl 6简单的数据库接口</li>
	<li> Zavolaj  - 从Rakudo Perl 6中调用C库函数</li>
	<li> SVG、SVG::Plot - 创建可缩放向量图形（"scalable vector graphics, SVG"）</li>
	<li> HTTP::Daemon - 一个简单的HTTP服务器</li>
	<li> XML::Writer  - 生成XML</li>
	<li> YAML - 转储Perl 6对象为YAML</li>
	<li> Term::ANSIColor - 利用ANSI转义序列产生彩色屏幕输出</li>
	<li> Test::Mock  - 创建mock对象并检查什么方法被调用</li>
	<li> Math::Model - 描述并运行数学模型</li>
	<li> Config::INI - 解析并编写配置文件</li>
	<li> File::Find  - 在给定的目录中查找文件</li>
	<li> LWP::Simple - 从Web中获取资源</li>
</ul>

<p>这些并不算作"Perl 6核心模块"，随Perl 6模块的开发成熟，Rakudo Star的未来版本中很可能将捆绑另一组模块，捆绑模块的推荐准则将随时间推进制定，同时其他Perl 6发行版可选择不同的模块和准则。有关Perl6模块的更多信息可于http://modules.perl6.org 找到。</p>

<p>Rakudo Star同时包含一份Perl 6指南读物的草稿──参看tar源码包中"docs/UsingPerl6-draft.pdf"。</p>

<p>开发组谨向所有使Rakudo Star顺利发布成为可能的贡献者、赞助者表示感谢。如果你想参与贡献，请参考http://rakudo.org/how-to-help，或向perl6-compiler@perl.org邮件列表提问，或加入我们在FreeNode上的#perl6 IRC频道。</p>

<p>Rakudo Star 在正常情况下将按月，或按缺陷修复、大幅改进之需发布。下一个Rakudo Star版本的发布日期拟定于2010年8月24日。</p>

<p>[1] http://github.com/rakudo/rakudo<br />
[2] http://parrot.org/<br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Read (the perldoc) carefully</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/pid/2010/06/read-the-perldoc-carefully.html" />
    <id>tag:blogs.perl.org,2010:/users/pid//89.618</id>

    <published>2010-06-07T08:56:45Z</published>
    <updated>2010-06-08T02:07:48Z</updated>

    <summary>Another day in CGI/CGI::Application brought me another question. My code: ... ... $out .= $cgi-&gt;hidden(&apos;rm&apos;, &apos;mode2&apos;); ... ... return $out; Seems to be OK, just like the example code below, a little bit different though: $output .= $q-&gt;hidden(-name =&gt; &apos;rm&apos;,...</summary>
    <author>
        <name>pid</name>
        
    </author>
    
    <category term="cgi" label="CGI" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perldoc" label="perldoc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rtfm" label="RTFM" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/pid/">
        <![CDATA[<p>Another day in <a href="http://search.cpan.org/perldoc?CGI">CGI</a>/<a href="http://search.cpan.org/perldoc?CGI::Application">CGI::Application</a> brought me another question.</p>

<p>My code:</p>

<pre><code class="prettyprint">    ... ...
    $out .= $cgi->hidden('rm', 'mode2');
    ... ...
    return $out;
</code></pre>

<p>Seems to be OK, just like the example code below, a little bit different though:</p>

<pre><code class="prettyprint">$output .= $q->hidden(-name => 'rm', -value => 'mode2');</code></pre>

<p>And if I use a URL like this: "http://www.example.org/cgi-bin/page.cgi?rm=whatever", then the value of the hidden field will now become "<code>whatever</code>".</p>

<p>I thought it was immutable, just like you've written the following line in your code:</p>

<pre><code class="prettyprint">$out .= '&lt;input type="hidden" name="rm"  value="mode2"  /&gt;';</code></pre>

<p>The truth proved me wrong. So, what's wrong? I decided to read <a href="http://cpansearch.perl.org/src/MARKSTOS/CGI-Application-4.31/lib/CGI/Application.pm">the source code of CGI.pm</a>. Let's walk through the "<code>hidden</code>" subroutine.</p>

<pre><code class="prettyprint">sub hidden {
    my($self,@p) = self_or_default(@_);
</code></pre>

<p><code>&self_or_default()</code> doesn't matter here. Now <code>@p</code> contains the list of <code>('-name', 'rm', '-value', 'mode2')</code>. (I should use <code>qw()</code> instead...)</p>

<pre><code class="prettyprint">my(@result,@value);
my($name,$default,$override,@other) = 
    rearrange([NAME,[DEFAULT,VALUE,VALUES],[OVERRIDE,FORCE]],@p);</code></pre>

<p><code>&rearrange()</code> is the "smart rearrangement" subroutine, it rearranges the <code>@p</code> according to the array reference given as its first argument. (It uses a hash to write down the "name => index" pairs, i.e., where the elements in <code>@p</code> are located (E.g. <code>$pos{NAME}</code> will be 0, <code>$pos{DEFAULT}</code>/<code>$pos{VALUE}</code>/<code>$pos{VALUES}</code> will be 1, etc.), fills them into a "result" array and then return it.) Here, no doubt, <code>$name</code> got <code>'rm'</code>, <code>$default</code> got <code>'mode2'</code>, and <code>$override</code> got an <code>undef</code>.</p>

<pre><code class="prettyprint">my $do_override = 0;
if (ref($p[0]) || substr($p[0],0,1) eq '-') {
        @value = ref($default) ? @{$default} : $default;
        $do_override = $override;
} else {
        ... ...
}</code></pre>

<p><code>substr($p[0],0,1) eq '-'</code> is true, <code>@value</code> now holds <code>'mode2'</code>, <code>$do_override</code> is <code>undef</code>. At first I don't know you can assign a scalar to an array without warnings (I tested & confirmed it with Perl 5.10.1). Maybe it should be written as <code>@value = ref($default) ? @{$default} : ($default);</code>?</p>

<pre><code class="prettyprint">my @prev = $self->param($name);
@value = @prev if !$do_override && @prev;</code></pre>

<p>Here I got what I want. <code>@value</code> is now assigned to whatever comes from the CGI parameter with the name of <code>$name</code> (<code>'rm'</code> in this case). And the solution is an easy one:</p>

<pre><code class="prettyprint">$output .= $q->hidden(-name => 'rm', -value => 'mode2', -override => 'yes');</code></pre>

<p>After making sure that the code is now running correctly, I read the perldoc again, particularly at "<a href="http://perldoc.perl.org/CGI.html#SETTING-THE-VALUE(S)-OF-A-NAMED-PARAMETER%3a">Setting the Value(s) of a Named Parameter</a>":</p>

<blockquote>This sets the value for the named parameter 'foo' to an array of values. This is one way to change the value of a field AFTER the script has been invoked once before. <em><strong>(Another way is with the -override parameter accepted by all methods that generate form elements.)</strong></em></blockquote>

<p>I also learned the meaning of "override": override the passed-in value with the one you gave to <code>hidden</code> method.</p>

<p>More of the story:</p>

<p>I am pretty sure someone (including me) once wrote the following code to reverse a string:</p>

<pre><code class="prettyprint">my $str = "Hello, World!";
my @chars = split '', $str;
my @reversed_chars = reverse @chars;
my $reversed_str = join '', @reversed_chars;
print "reversed_str";
</code></pre>

<p>Or in a single line as a proof of progress:</p>

<pre><code class="prettyprint">print join '', reverse split '', $str;</code></pre>

<p>If you ever read the <a href="http://perldoc.perl.org/functions/reverse.html">perldoc of reverse</a>, it's not hard to figure out a better way of doing this:</p>

<pre><code class="prettyprint">print scalar reverse $str;</code></pre>

<p>Read the perldoc carefully (read the source code, the ultimate document, when needed).<br />
RTFM as we all say, it worthing the repeating.<br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>The last statement</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/pid/2010/06/the-last-statement.html" />
    <id>tag:blogs.perl.org,2010:/users/pid//89.614</id>

    <published>2010-06-06T13:07:25Z</published>
    <updated>2010-06-07T03:03:52Z</updated>

    <summary>Days ago, I was learning to use CGI::Application. After finished my baby &quot;run mode&quot;, I opened my browser to give it a shot. It worked, and I start wondering why it worked. The last statements of those examples are return...</summary>
    <author>
        <name>pid</name>
        
    </author>
    
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/pid/">
        <![CDATA[<p>Days ago, I was learning to use <a href="http://search.cpan.org/perldoc?CGI::Application">CGI::Application</a>. </p>

<p>After finished my baby "run mode", I opened my browser to give it a shot. It worked, and I start wondering why it worked. The last statements of those examples are</p>

<pre><code class="prettyprint">return $output;</code></pre>

<p>Mine's not, it looked like this(I forgot to add "<code>return</code>" by accident): </p>

<pre><code class="prettyprint">sub run_mode_1 {
    my $self   = shift;
    my $query  = $self->query();
    my $output = q[];
    ... ... 
    $output .= $query->end_html;
}
</code>
</pre>

<p>Suddenly I realized <em>it</em>'s the last statement! Its value had become the return value of the subroutine(As far as I know, it must return something, either through a "<code>return</code>" or the last expression evaluated). There's no black magic for that, everything went on well enough.</p>

<p>For a code block, the trailing semicolon of the last statement can be omitted. It's an eye-candy for using in some scenario such as <code><a href="http://perldoc.perl.org/functions/map.html">map</a></code>/<code><a href="http://perldoc.perl.org/functions/grep.html">grep</a></code>.</p>

<p>For a module, the last statement must be a true value, the commonly-used one is "<code>1;</code>" or you'll get lines like this:</p>

<pre>
Homework.pm: Your/Homework.pm did not return a true value at homework.pl line 4.
BEGIN failed--compilation aborted at homework.pl line 4.
</pre>

<p><br />
<code>__END__</code></p>

<p>It("<code>__END__</code>" or "<code>__DATA__</code>") is yet-another-last-statement. As Larry told us in <a href="http://wall.org/~larry/natural.html">this</a> article, we put this at the ending of our scripts as if we just told people "and they lived happily ever after". Everything comes after will not be treat as Perl code, and can access via a special file handle called "<code>DATA</code>".</p>]]>
        
    </content>
</entry>

<entry>
    <title>What my experienced business manager would ask about Perl</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/pid/2010/05/what-my-experienced-business-manager-would-ask-about-perl.html" />
    <id>tag:blogs.perl.org,2010:/users/pid//89.596</id>

    <published>2010-05-31T09:13:55Z</published>
    <updated>2010-05-31T09:20:32Z</updated>

    <summary> Can it be compared with J2EE? CGI? That&apos;s even older than ASP, you cannot write my webapp in it! Does Perl support session? I can let you try to code at most 20% of my webapp(you can&apos;t code the...</summary>
    <author>
        <name>pid</name>
        
    </author>
    
    <category term="business" label="Business" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/pid/">
        <![CDATA[<ul>
	<li>Can it be compared with J2EE?</li>
	<li>CGI? That's even older than ASP, you cannot write my webapp in it!</li>
	<li>Does Perl support session?</li>
	<li>I can let you try to code at most 20% of my webapp(you can't code the whole site with Perl, apparently), but make sure it can share session with ASP.NET.</li>
	<li>What's needed to run your Perl?</li>
	<li>Is there anything Perl can do better than Java?</li>
	<li>Does Perl have business value?</li>
</ul>

<p>Like Damian said in <a href="http://www.oreillygmt.co.uk/2010/05/damian-conway-on-perl-and-its-future.html">this</a> interview: <em>"Selling Perl to your manager is about explaining Perl in terms that your manager cares about: stable, reliable, powerful, efficient, cheap, maintainable, well-supported, and future-proof."</em></p>

<p>Are we sharing the same situation here?</p>]]>
        
    </content>
</entry>

</feed>
