<?xml version="1.0"?>
<!-- name="generator" content="blosxom/2.0" -->
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">
  <channel>
    <title>&#36339;&#12397;&#36796;&#12416;&#12398;&#26085;&#35352; - hanekomu's Perl blog   </title>
    <link>http://hanekomu.at/blog</link>
    <description>&#36339;&#12397;&#36796;&#12416; - hanekomu's Perl blog.</description>
    <language>en</language>

<item>
    <title>Current git branch in the bash prompt</title>
    <pubDate>Fri, 16 Jul 2010 18:41:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/misc/20100716-1841-current_git_branch_in_bash_prompt.html</link>
    <description>&lt;p&gt;You can use &lt;code&gt;git branch&lt;/code&gt; to see the branch you're currently in,
but it's easy to forget and to commit something into the wrong branch.&lt;/p&gt;

&lt;p&gt;I wanted to have a constant reminder, so I chose to display the current
branch on the bash prompt.&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
function parse_git_branch {
   ref=$(git symbolic-ref HEAD 2&amp;gt; /dev/null) || return
   printf &amp;quot; (${ref#refs/heads/})&amp;quot;
}

export PS1=&amp;quot;\$(parse_git_branch) \$ &amp;quot;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The first backslash in &lt;code&gt;PS1&lt;/code&gt; is important so the function gets
evaluated for every new bash prompt. If you're not inside a git repository,
nothing will be printed. Let's see this in action.&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
 $ git init
Initialized empty Git repository in /path/to/repo/.git/
 (master) $ git checkout -b newbranch
Switched to a new branch &amp;#39;newbranch&amp;#39;
 (newbranch) $ git checkout master
Switched to branch &amp;#39;master&amp;#39;
 (master) $ cd ~
 $ 
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This is just a bare shell prompt and actually I have a rather &quot;baroque&quot;
&lt;code&gt;PS1&lt;/code&gt; setting, but that's for another blog post.&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/misc/20100716-1841-current_git_branch_in_bash_prompt.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/misc/20100716-1841-current_git_branch_in_bash_prompt.rss', 'Current git branch in the bash prompt')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>Modern Perl administration tools</title>
    <pubDate>Fri, 16 Jul 2010 15:56:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/cpan_gems/20100716-1556-modern_perl_administration_tools.html</link>
    <description>&lt;p&gt;I'm probably preaching to the choir (the phrase we use in German is more
like &quot;bringing owls to Athens&quot;) and I'm certainly not saying anything new here,
but I would like to talk about two modern tools that make working with Perl
versions and CPAN distributions very easy: &lt;code&gt;perlbrew&lt;/code&gt; and
&lt;code&gt;cpanm&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;perlbrew&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;perlbrew&lt;/code&gt; (see &lt;a href=&quot;http://search.cpan.org/dist/App-perlbrew/&quot;&gt;App::perlbrew&lt;/a&gt;) automates
building and installing various perl versions in the user's home directory.&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
curl -LO http://xrl.us/perlbrew
chmod +x perlbrew
./perlbrew install
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With this, perlbrew installs itself to &lt;code&gt;~/perl5/perlbrew&lt;/code&gt;. Now
you can do (and I'm quoting from the App::perlbrew documentation):&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
# Initialize
perlbrew init

# Install some Perls
perlbrew install perl-5.12.1
perlbrew install perl-5.8.1
perlbrew install perl-5.11.5

# See what were installed
perlbrew installed

# Switch perl in the $PATH
perlbrew switch perl-5.12.1
perl -v

# Switch to another version
perlbrew switch perl-5.8.1
perl -v

# Switch to a certain perl executable not managed by perlbrew.
perlbrew switch /usr/bin/perl

# Or turn it off completely. Useful when you messed up too deep.
perlbrew off

# Use &amp;#39;switch&amp;#39; command to turn it back on.
perlbrew switch perl-5.12.1
&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;cpanm&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cpanm&lt;/code&gt; is a script to get, unpack, build and install modules
from CPAN. It does so in pretty much the simplest way possible, without
dependencies or configuration.&lt;/p&gt;

&lt;p&gt;To install it onto a freshly brewed perl, use this command:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
curl -L http://cpanmin.us/ | perl - App::cpanminus
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then you can do (and again, I'm quoting from the App::cpanminus
documentation):&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
cpanm Test::More                                 # install Test::More
cpanm MIYAGAWA/Plack-0.99_05.tar.gz              # full distribution path
cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz  # install from URL
cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz   # install from a local file
cpanm --interactive Task::Kensho                 # Configure interactively
cpanm .                                          # install from local directory
cpanm --installdeps .                            # install all deps for the current dir
cpanm -L extlib Plack                            # install Plack and its deps to extlib
cpanm --mirror http://cpan.cpantesters.org/ DBI  # use the fast-syncing mirror
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;cpanm --installdeps .&lt;/code&gt; command will work if you have a
&lt;code&gt;Makefile.PL&lt;/code&gt; or a &lt;code&gt;Build.PL&lt;/code&gt; in the current directory,
but if you use &lt;a href=&quot;http://search.cpan.org/dist/Dist-Zilla/&quot;&gt;Dist::Zilla&lt;/a&gt; you're likely to use a plugin
that generates the &lt;code&gt;Makefile.PL&lt;/code&gt; and the dependencies for you. In
that case you can use this:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
dzil listdeps | cpanm --skip-installed
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Another tool that works well with &lt;code&gt;cpanm&lt;/code&gt; is
&lt;code&gt;cpan-outdated&lt;/code&gt; (see &lt;a href=&quot;http://search.cpan.org/dist/App-cpanoutdated/&quot;&gt;App::cpanoutdated&lt;/a&gt;). It will
simply list all the outdated modules' distribution names in a format that can
be directly passed to &lt;code&gt;cpanm&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
cpan-outdated | cpanm
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There are some modules that I need for every Perl installation that I'm
working with, and I've bundled them into &lt;a href=&quot;http://search.cpan.org/dist/Task-BeLike-hanekomu/&quot;&gt;Task::BeLike::hanekomu&lt;/a&gt;. So after brewing a new version of
perl, I'll do:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
cpanm Task::BeLike::hanekomu
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and get all the absolute necessities like App::Ack, App::Rgit,
Devel::NYTProf and so on.&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/cpan_gems/20100716-1556-modern_perl_administration_tools.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/cpan_gems/20100716-1556-modern_perl_administration_tools.rss', 'Modern Perl administration tools')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>bash brace expansion</title>
    <pubDate>Fri, 28 May 2010 10:12:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/dev/20100528-1012-bash_brace_expansion.html</link>
    <description>&lt;p&gt;Last time we looked at &lt;a
href=&quot;http://hanekomu.at/blog/dev/20100525-2331-bash_parameter_expansion.html&quot;&gt;bash
parameter expansion&lt;/a&gt;. Now I would like to talk about bash brace expansion.
This is mainly a blog about Perl, but Unix tools like shells and editors are
part of a Perl programmer's life as well, so from time to time I'll write about
those tools too.&lt;/p&gt;

&lt;p&gt;Brace expansion in bash is a way of generating strings. The most general
form is a list of strings within braces, separated by commas. There can be
other strings before and/or after the braces; they will be included in all
variations. For example:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
$ echo {foo,baz,baz}
foo baz baz

$ echo prefix-{foo,bar,baz}-suffix
prefix-foo-suffix prefix-bar-suffix prefix-baz-suffix

$ for i in {foo,bar,baz}; do echo $i; done
foo
bar
baz
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Brace expansion can be turned on and off using bash's &lt;code&gt;B&lt;/code&gt; option.
&lt;code&gt;+B&lt;/code&gt; turns brace expansion off, &lt;code&gt;-B&lt;/code&gt; turns it back
on.&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
$ set +B

$ echo {foo,baz,baz}
{foo,baz,baz}

$ set -B

$ echo {foo,baz,baz}
foo baz baz
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Here are some easy examples that show what is possible:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
$ echo foo{,,,}
foo foo foo foo

$ echo {1..3}{1..3}{1..3}
111 112 113 121 122 123 131 132 133 211 212 213 221 222
223 231 232 233 311 312 313 321 322 323 331 332 333

$ echo {foo,bar,baz}{1..3}
foo1 foo2 foo3 bar1 bar2 bar3 baz1 baz2 baz3

$ echo {foo{1..3},bar{4..6},baz{7..9}}
foo1 foo2 foo3 bar4 bar5 bar6 baz7 baz8 baz9

$ cp /some/very/long/path/to/my.conf{,.bak}
cp /some/very/long/path/to/my.conf /some/very/long/path/to/my.conf.bak

$ mkdir -p /Foo-Bar/{bin,lib,eg,t}
mkdir -p /Foo-Bar/bin /Foo-Bar/lib /Foo-Bar/eg /Foo-Bar/t

$ mv foo{,-}bar
mv foobar foo-bar
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can also specify ranges using the &lt;code&gt;{from..to}&lt;/code&gt; syntax, and
ranges with steps using the &lt;code&gt;{from..to..step}&lt;/code&gt; syntax. These ranges
can be numeric or alphabetic.&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
$ echo {1..5}
1 2 3 4 5

$ echo {5..1}
5 4 3 2 1

$ echo {3..-3}
3 2 1 0 -1 -2 -3

$ echo {1..10..2}
1 3 5 7 9

$ echo {a..e}
a b c d e

$ echo {e..a}
e d c b a

$ echo {a..z..2}
a c e g i k m o q s u w y
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;One typical use for brace expansion is to tell wget or curl to download
several files whose URLs conform to a certain pattern:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
$ wget http://example.com/path/to/{014..017}.{html,png}
wget http://example.com/path/to/014.html http://example.com/path/to/014.png
http://example.com/path/to/015.html http://example.com/path/to/015.png
http://example.com/path/to/016.html http://example.com/path/to/016.png
http://example.com/path/to/017.html http://example.com/path/to/017.png
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;(bash version 4 retains leading zeros; earlier bash versions omitted
them.)&lt;/p&gt;

&lt;p&gt;I also use brace expansion in my &lt;code&gt;~/.bashrc&lt;/code&gt; to inspect certain
directories to find out whether to they contain &lt;code&gt;bin/&lt;/code&gt;,
&lt;code&gt;sbin/&lt;/code&gt; or &lt;code&gt;man/&lt;/code&gt; subdirectories that should be added to
&lt;code&gt;$PATH&lt;/code&gt; and &lt;code&gt;$MANPATH&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
for d in {/usr,/opt,~}{,/{local,share,local/share,perl,perl/5.*.*}}
do
    test -d &amp;quot;$d/bin&amp;quot; &amp;amp;&amp;amp; PATH=&amp;quot;$d/bin:$PATH&amp;quot;
    test -d &amp;quot;$d/sbin&amp;quot; &amp;amp;&amp;amp; PATH=&amp;quot;$d/sbin:$PATH&amp;quot;
    test -d &amp;quot;$d/man&amp;quot; &amp;amp;&amp;amp; MANPATH=&amp;quot;$d/man:$MANPATH&amp;quot;
done
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This effectively iterates over all of these directories:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
/usr
/usr/local
/usr/share
/usr/local/share
/usr/perl
/usr/perl/5.*.*
/opt
/opt/local
/opt/share
/opt/local/share
/opt/perl
/opt/perl/5.*.*
~
~/local
~/share
~/local/share
~/perl
~/perl/5.*.*
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Do you have interesting examples of using the bash brace expansion mechanism?&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/dev/20100528-1012-bash_brace_expansion.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/dev/20100528-1012-bash_brace_expansion.rss', 'bash brace expansion')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>Aspect-Oriented Programming, Reloaded</title>
    <pubDate>Thu, 27 May 2010 12:02:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/dev/20100527-1202-aspect_oriented_programming_reloaded.html</link>
    <description>&lt;p&gt;Back in 2001, I wrote Aspect.pm, which brought Aspect-Oriented Programming
(AOP) to Perl. It was a neat toy, but to be honest, for me that's all it ever
was. I never used it even in tests, much less in production.&lt;/p&gt;

&lt;p&gt;Now that Adam Kennedy++ has taken over maintenance of the &lt;a href=&quot;http://search.cpan.org/dist/Aspect/&quot;&gt;Aspect&lt;/a&gt; distribution, he has rewritten its core, introduced new
pointcuts and join point types and &lt;a
href=&quot;http://use.perl.org/~Alias/journal/40368&quot;&gt;wrote a blog post&lt;/a&gt; in which
he details the future plans for AOP in Perl.&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/dev/20100527-1202-aspect_oriented_programming_reloaded.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/dev/20100527-1202-aspect_oriented_programming_reloaded.rss', 'Aspect-Oriented Programming, Reloaded')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>bash parameter expansion</title>
    <pubDate>Tue, 25 May 2010 23:31:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/dev/20100525-2331-bash_parameter_expansion.html</link>
    <description>&lt;p&gt;The bash shell, especially in version 4, has useful parameter expansion
features. I've only just started to really use them, so I wanted to make a note
of the ones that seem most interesting.&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
$ foo=&amp;quot;hello world goodbye world&amp;quot;
$ echo &amp;quot;${foo/world/perl}&amp;quot;
hello perl goodbye world
$ echo &amp;quot;${foo//world/perl}&amp;quot;
hello perl goodbye perl
$ echo &amp;quot;${foo^}&amp;quot;
Hello world goodbye world
$ echo &amp;quot;${foo^^}&amp;quot;
HELLO WORLD GOODBYE WORLD

bar=&amp;quot;HELLO&amp;quot;
$ echo &amp;quot;${bar,}&amp;quot;
hELLO
$ echo &amp;quot;${bar,,}&amp;quot;
hello

$ path=&amp;quot;/path/to/the/script&amp;quot;
$ echo &amp;quot;dirname  = ${path%/*}&amp;quot;
dirname  = /path/to/the
$ echo &amp;quot;basename = ${path##*/}&amp;quot;
basename = script
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As you can see, &lt;code&gt;${foo/bar/baz}&lt;/code&gt; takes the contents of the
variable &lt;code&gt;foo&lt;/code&gt;, substitutes the first occurrence of &lt;code&gt;bar&lt;/code&gt;
with &lt;code&gt;baz&lt;/code&gt; and returns the result. The contents of &lt;code&gt;foo&lt;/code&gt;
are unaltered. If you want to replace all occurrences, not just the first, use
&lt;code&gt;${foo//bar/baz}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Starting with bash version 4, &lt;code&gt;${foo^}&lt;/code&gt; uppercases the first
character, while &lt;code&gt;${foo^^}&lt;/code&gt; uppercases the whole string. Likewise,
&lt;code&gt;{$foo,}&lt;/code&gt; lowercases the first character and &lt;code&gt;{$foo,,}&lt;/code&gt;
lowercases the whole string.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;${foo#pattern}&lt;/code&gt; tries to match the pattern from the start of the
string and deletes the matching part of the string.
&lt;code&gt;${foo##pattern}&lt;/code&gt; is the greedy version. In the example above, to
get the directory path, we greedily delete everything from the start of the
string to the final slash: &lt;code&gt;${path##*/}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There is also &lt;code&gt;${foo%pattern}&lt;/code&gt;, which also deletes, but starts
looking from the end of the string. &lt;code&gt;${foo%%pattern}&lt;/code&gt; is the greedy
version. In the example above, to get the filename, we delete everything from
the final slash &amp;mdash; that is, we start looking from the end until we find a
slash: &lt;code&gt;${path%/*}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Using the above techniques you might not need to invoke the external
&lt;code&gt;dirname&lt;/code&gt; and &lt;code&gt;basename&lt;/code&gt; programs, as the shell built-in
features are powerful enough.&lt;/p&gt;

&lt;p&gt;There is a lot more to parameter expansion. See &lt;code&gt;man bash&lt;/code&gt; for
more details.&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/dev/20100525-2331-bash_parameter_expansion.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/dev/20100525-2331-bash_parameter_expansion.rss', 'bash parameter expansion')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>PAUSE Web Service API and other Perl QA Hackathon results</title>
    <pubDate>Wed, 14 Apr 2010 10:26:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/dev/20100414-1026-pause_web_service_api_and_other_perl_qa_hackathon_results.html</link>
    <description>&lt;p&gt;In this blog post I'd like to talk about what I got done during the Perl QA
Hackathon.&lt;/p&gt;

&lt;p&gt;On Saturday I wrote a command for Dist::Zilla that uses Devel::Cover to
generate code coverage metrics for a distribution: &lt;a &lt;a href=&quot;http://search.cpan.org/dist/Dist-Zilla-App-Command-cover/&quot;&gt;Dist::Zilla::App::Command::cover&lt;/a&gt;. Also I added plugin support
to &lt;a href=&quot;http://search.cpan.org/dist/App-perlzonji/&quot;&gt;App::perlzonji&lt;/a&gt; (the more knowledgeable perldoc) so you
can provide your own information sources. Ovid got interested in &lt;a href=&quot;http://search.cpan.org/dist/DB-Pluggable/&quot;&gt;DB::Pluggable&lt;/a&gt; and wrote &lt;a href=&quot;http://search.cpan.org/dist/DB-Pluggable-Dumper/&quot;&gt;DB::Pluggable::Dumper&lt;/a&gt;; I'll try to refactor part of his work back into the main module.&lt;/p&gt;

&lt;p&gt;On Sunday I talked with Andreas K&amp;ouml;nig about a Web Service API for &lt;a
href=&quot;http://pause.perl.org/&quot;&gt;PAUSE&lt;/a&gt;. I want to be able to edit maintainership
permissions, add module registration metadata and delete files without having
to use the PAUSE web site. Andreas agreed that this would be a good thing to
have. In the first phase, to see how this all works out, we'll provide
read-only access to the PAUSE data.&lt;/p&gt;

&lt;p&gt;Writing a PSGI/Plack application was the obvious choice, and during dinner
on Sunday evening miyagawa explained to me how &lt;a href=&quot;http://search.cpan.org/dist/Tatsumaki/&quot;&gt;Tatsumaki&lt;/a&gt;
works. On Monday rafl, whose computer had unfortunately stopped working on
Sunday, helped me with using non-blocking features of Tatsumaki.&lt;/p&gt;

&lt;p&gt;Basically Tatsumaki is a framework for writing PSGI applications. Of course
you can write raw PSGI applications, but Tatsumaki offers non-blocking support,
path routing and takes care of the request and response objects for you.
Writing a proof-of-concept PAUSE Web Service only took a few dozen lines. The
API so far only consists of a few minor GET URLs and is not live yet. Have a
look at &lt;a href=&quot;http://github.com/hanekomu/PAUSE-Web&quot;&gt;PAUSE-Web&lt;/a&gt; on
GitHub.&lt;/p&gt;

&lt;p&gt;I also wrote a PAUSE client library to talk to the API, see &lt;a
href=&quot;http://github.com/hanekomu/PAUSE-Client&quot;&gt;PAUSE-Client&lt;/a&gt; on GitHub. This
was really easy thanks to &lt;a href=&quot;http://search.cpan.org/dist/WebService-Simple/&quot;&gt;WebService::Simple&lt;/a&gt;.

&lt;p&gt;In future posts I will talk more about the PAUSE Web Service API and how it
is implemented.&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/dev/20100414-1026-pause_web_service_api_and_other_perl_qa_hackathon_results.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/dev/20100414-1026-pause_web_service_api_and_other_perl_qa_hackathon_results.rss', 'PAUSE Web Service API and other Perl QA Hackathon results')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>This was the Perl QA Hackathon in Vienna</title>
    <pubDate>Tue, 13 Apr 2010 16:54:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/conferences/20100413-1654-this_was_the_perl_qa_hackathon_in_vienna.html</link>
    <description>&lt;p&gt;The &lt;a href=&quot;http://2010.qa-hackathon.org/&quot;&gt;Perl QA Hackathon 2010&lt;/a&gt; in
Vienna is over and has been a great success. It was fun, interesting,
inspiring, intensive and tiring. Seeing the Perl friends again felt very
good.&lt;/p&gt;

&lt;p&gt;We met on Friday early evening and parted on Monday late evening, so the
hackathon was about as long as a YAPC would be, but because there were only
about thirty people and they were all in the same room, it was much easier to
talk to everyone, exchange ideas and work together.&lt;/p&gt;

&lt;p&gt;Flights, hotel costs, lunches, dinners, drinks and snacks were all paid for
by Vienna.pm with the help of the hackathon sponsors, &lt;a
href=&quot;http://www.123people.at/&quot;&gt;123people.at&lt;/a&gt; and the &lt;a
href=&quot;http://www.obvsg.at/&quot;&gt;&amp;Ouml;sterreichische Bibliothekenverbund&lt;/a&gt; (the
Austrian Library Network and Services Ltd).&lt;/a&gt;

&lt;p&gt;I've uploaded my &lt;a
href=&quot;http://www.flickr.com/photos/hanekomu/sets/72157623846296178/&quot;&gt;photos&lt;/a&gt;
from the weekend to Flickr.&lt;/p&gt;

&lt;p&gt;
&lt;object width=&quot;400&quot; height=&quot;300&quot;&gt; &lt;param name=&quot;flashvars&quot; value=&quot;offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2Fhanekomu%2Fsets%2F72157623846296178%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2Fhanekomu%2Fsets%2F72157623846296178%2F&amp;set_id=72157623846296178&amp;jump_to=&quot;&gt;&lt;/param&gt; &lt;param name=&quot;movie&quot; value=&quot;http://www.flickr.com/apps/slideshow/show.swf?v=71649&quot;&gt;&lt;/param&gt; &lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;embed type=&quot;application/x-shockwave-flash&quot; src=&quot;http://www.flickr.com/apps/slideshow/show.swf?v=71649&quot; allowFullScreen=&quot;true&quot; flashvars=&quot;offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2Fhanekomu%2Fsets%2F72157623846296178%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2Fhanekomu%2Fsets%2F72157623846296178%2F&amp;set_id=72157623846296178&amp;jump_to=&quot; width=&quot;400&quot; height=&quot;300&quot;&gt;&lt;/embed&gt;&lt;/object&gt;
&lt;/p&gt;

&lt;p&gt;On Sunday and Monday there were a total of three stand-up sessions where
each of us talked a bit about what he had achieved so far. brian d foy recorded
them:&lt;/p&gt;

&lt;ul&gt;

&lt;li&gt;&lt;a
href=&quot;http://blogs.perl.org/users/brian_d_foy/2010/04/2010-vienna-qa-workshop-day-1-results-video.html&quot;&gt;Day
1 results&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a
href=&quot;http://blogs.perl.org/users/brian_d_foy/2010/04/2010-vienna-qa-workshop-day-2-results-video.html&quot;&gt;Day
2 results&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a
href=&quot;http://blogs.perl.org/users/brian_d_foy/2010/04/2010-vienna-qa-workshop-final-summary-video.html&quot;&gt;Final
summary&lt;/a&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;domm &lt;a
href=&quot;http://blogs.perl.org/users/domm/2010/04/perl-qa-hackthon-day-1.html&quot;&gt;blogged&lt;/a&gt;
about the first day of the hackathon as well. Ovid &lt;a
href=&quot;http://blogs.perl.org/users/ovid/&quot;&gt;wrote&lt;/a&gt; about his work at the
hackathon.&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/conferences/20100413-1654-this_was_the_perl_qa_hackathon_in_vienna.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/conferences/20100413-1654-this_was_the_perl_qa_hackathon_in_vienna.rss', 'This was the Perl QA Hackathon in Vienna')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>The CPAN Leaderboard as an arcade game High Score screen</title>
    <pubDate>Thu, 01 Apr 2010 15:13:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/misc/20100401-1513-cpan_leaderboard_as_an_arcade_game_high_score_screen.html</link>
    <description>&lt;p&gt;The &lt;a href=&quot;http://thegestalt.org/simon/perl/wholecpan.html&quot;&gt;CPAN
Leaderboard&lt;/a&gt; shows CPAN authors ranked by the number of modules &amp;mdash; but
use this with care as it doesn't say anything about the quality of one author's
distribution.&lt;/p&gt;

&lt;p&gt;If CPAN was an arcade game, its high score screen might look a bit like
this:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/hanekomu/4481674104/&quot; title=&quot;CPAN Leaderboard as arcade game High Score screen by hanekomu, on Flickr&quot;&gt;&lt;img src=&quot;http://farm3.static.flickr.com/2796/4481674104_3bec7b6eff.jpg&quot; width=&quot;500&quot; height=&quot;354&quot; alt=&quot;CPAN Leaderboard as arcade game High Score screen&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/misc/20100401-1513-cpan_leaderboard_as_an_arcade_game_high_score_screen.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/misc/20100401-1513-cpan_leaderboard_as_an_arcade_game_high_score_screen.rss', 'The CPAN Leaderboard as an arcade game High Score screen')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>Boolean normalization using the logical negation operator</title>
    <pubDate>Thu, 18 Mar 2010 08:22:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/dev/20100318-0822-boolean_normalization_using_the_logical_negation_operator.html</link>
    <description>&lt;p&gt;The &lt;code&gt;perlsyn&lt;/code&gt; manpage says the following about truth and
falsehood:&lt;/p&gt;

&lt;p class=&quot;quote&quot;&gt;The number 0, the strings '0' and '', the empty list &quot;()&quot;, and
&quot;undef&quot; are all false in a boolean context. All other values are true. Negation
of a true value by &quot;!&quot; or &quot;not&quot; returns a special false value. When evaluated
as a string it is treated as '', but as a number, it is treated as 0.&lt;/p&gt;

&lt;p&gt;Sometimes you want to normalize a value so that it is 1 if it is a true
value and 0 if it is a false value. This is sometimes called boolean
normalization.&lt;/p&gt;

&lt;p&gt;Usually you will see something like this:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;$b&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;$value&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There is an easier way. You could make use of the logical negation operator,
&lt;code&gt;!&lt;/code&gt;. When it is applied to a true value, it returns a dual value
that is the number zero in numerical context and the empty string in string
context. When the logical negation operator is applied to a false value, it
returns a dual value that is the number 1 in numerical context and the string
&lt;code&gt;&quot;1&quot;&lt;/code&gt; in string context. Let's see this in detail:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;
$ perl -MDevel::Peek -le&amp;#39;Dump !42&amp;#39;
SV = PVNV(0x802000) at 0x12fef8
  REFCNT = 2147483647
  FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
  IV = 0
  NV = 0
  PV = 0x200160 &amp;quot;&amp;quot;\0
  CUR = 0
  LEN = 4

$ perl -MDevel::Peek -le&amp;#39;Dump !0&amp;#39;
SV = PVNV(0x802014) at 0x12ff08
  REFCNT = 2147483646
  FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
  IV = 1
  NV = 1
  PV = 0x200170 &amp;quot;1&amp;quot;\0
  CUR = 1
  LEN = 4
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;By using the logical negation operator twice you can therefore simplify the
above statement to:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;$b&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;!!&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And if you wanted the opposite boolean normalization, it's even easier:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;$b&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;$value&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;becomes:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;$b&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;symbol&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/dev/20100318-0822-boolean_normalization_using_the_logical_negation_operator.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/dev/20100318-0822-boolean_normalization_using_the_logical_negation_operator.rss', 'Boolean normalization using the logical negation operator')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item><item>
    <title>Use parent.pm instead of base.pm</title>
    <pubDate>Wed, 17 Mar 2010 23:26:00 GMT</pubDate>
    <link>http://hanekomu.at/blog/cpan_gems/20100317-2326-use_parent_instead_of_use_base.html</link>
    <description>&lt;p&gt;For years, the common way for your class to inherit from one or more
superclasses was the &lt;a href=&quot;http://search.cpan.org/dist/base/&quot;&gt;base&lt;/a&gt; module. For example:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;Game&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;sub&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;bless&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;core&quot;&gt;shift&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;keyword&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;Baduk&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;pragma&quot;&gt;base&lt;/span&gt; &lt;span class=&quot;single&quot;&gt;'Game'&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This works, but some people, me included, aren't quite happy with that.
Basically, the above could also be expressed as:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;Game&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;sub&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;bless&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;core&quot;&gt;shift&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;keyword&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;Baduk&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;our&lt;/span&gt; &lt;span class=&quot;symbol&quot;&gt;@ISA&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;words&quot;&gt;qw(Game)&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If the two packages were in different files, the &lt;code&gt;Baduk&lt;/code&gt; package
would have to load the file where the &lt;code&gt;Game&lt;/code&gt; package lives in as
well. But that's about it.&lt;/p&gt;

&lt;p&gt;However, &lt;code&gt;base.pm&lt;/code&gt; goes further than that. It supports deprecated
pseudohases, tries to be clever with &lt;code&gt;$VERSION&lt;/code&gt; and generally just
does too much. A lot of cruft has accumulated over the years. So a new module,
&lt;a href=&quot;http://search.cpan.org/dist/parent/&quot;&gt;parent&lt;/a&gt;, was forked from &lt;code&gt;base.pm&lt;/code&gt; and cleaned
up.&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;parent.pm&lt;/code&gt; is pretty much the same as
&lt;code&gt;base.pm&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;Game&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;sub&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;bless&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;core&quot;&gt;shift&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;keyword&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;Baduk&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;pragma&quot;&gt;parent&lt;/span&gt; &lt;span class=&quot;single&quot;&gt;'Game'&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This will try to load &lt;code&gt;Game.pm&lt;/code&gt; as well. If the &lt;code&gt;Game&lt;/code&gt;
package is in a different file that is already loaded, you can tell
&lt;code&gt;parent.pm&lt;/code&gt; not to try to load the file:&lt;/p&gt;

&lt;div class=&quot;perlsource&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;Game&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;sub&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;bless&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;core&quot;&gt;shift&lt;/span&gt; &lt;span class=&quot;structure&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;keyword&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;Baduk&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;pragma&quot;&gt;parent&lt;/span&gt; &lt;span class=&quot;word&quot;&gt;-norequire&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;single&quot;&gt;'Game'&lt;/span&gt;&lt;span class=&quot;structure&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Compare the source of the two modules and you will find that
&lt;code&gt;parent.pm&lt;/code&gt; is a lot cleaner and easier to understand.&lt;/p&gt;&lt;p&gt;
    &lt;a href=&quot;http://hanekomu.at/blog/cpan_gems/20100317-2326-use_parent_instead_of_use_base.html&quot;&gt;Write a comment&lt;/a&gt; | 
&lt;!-- AddThis Button BEGIN --&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, '', 'http://hanekomu.at/blog/cpan_gems/20100317-2326-use_parent_instead_of_use_base.rss', 'Use parent.pm instead of base.pm')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=hanekomu&quot;&gt;&lt;/script&gt;
&lt;!-- AddThis Button END --&gt;
&lt;/p&gt;

</description>
</item>  </channel>
</rss>