<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Perlsphere</title>
  <link rel="alternate" href="http://perlsphere.net/" type="text/html"/>
  <updated>2010-09-06T05:13:06+01:00</updated>
  <generator>Plagger/0.7.17</generator>
  <subtitle>The Perl firehose! The Web's biggest collection of Perl blogs.&lt;br /&gt;If you'd like your Perl blog or tech blog's Perl category to appear here, send mail to &amp;#108;&amp;#101;&amp;#111;&amp;#64;&amp;#99;&amp;#117;&amp;#99;&amp;#107;&amp;#111;&amp;#111;&amp;#46;&amp;#111;&amp;#114;&amp;#103;.</subtitle>
  <id>tag:perlsphere.net,2006:smartfeed:all</id>
  <entry>
    <title>Should Module::Install move to explicit plugin declaration?</title>
    <link rel="alternate" href="http://use.perl.org/~Alias/journal/40523?from=rss" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Module::Install has been through a long period of gradual stability over
the last year, without any really dramatic improvements to the grammar or
APIs.

With the more urgent "it doesn't work with blah" stuff mostly solved now,
one of the big remaining issues is around error clarity and excessive
magic.

For example, some random author that is trying to checkout a Catalyst
project needs:

1. To have Module::Install installed.
2. To have Module::Install::Catalyst installed.

In the case of the former, you get the semi-cryptic but at least standard
"Can't find inc/Module/Install.pm in @INC" message, so the error is
resolvable.

But in the latter case, you're likely to get something like "Unknown
command 'catalyst_ignore'", with no real obvious resolution mechanism.

I think this idea of automatic plugin discovery is starting to hit it's
limits in terms of clarity.

And so I'd like to do something counter to my natural instincts here, and
make M:I more verbose.

I'm thinking of something like the following for explicitly declaring the
use of a non-core Module::Install extension.

  use inc::Module::Install qw{ Catalyst XSUtil };

This would both allow M:I to error with a much more meaningful error when
you don't have a plugin, and also prevent the loading of unused plugins
which should prevent accidental plugin collisions (some of which I've
seen occurring in the CPAN Testers machines).

Thoughts?</div>
    </summary>
    <content type="html">&lt;p&gt;Module::Install has been through a long period of gradual stability over the last year, without any really dramatic improvements to the grammar or APIs.&lt;/p&gt;&lt;p&gt;With the more urgent "it doesn't work with blah" stuff mostly solved now, one of the big remaining issues is around error clarity and excessive magic.&lt;/p&gt;&lt;p&gt;For example, some random author that is trying to checkout a Catalyst project needs:&lt;/p&gt;&lt;p&gt;1. To have Module::Install installed.&lt;br&gt;2. To have Module::Install::Catalyst installed.&lt;/p&gt;&lt;p&gt;In the case of the former, you get the semi-cryptic but at least standard "Can't find inc/Module/Install.pm in @INC" message, so the error is resolvable.&lt;/p&gt;&lt;p&gt;But in the latter case, you're likely to get something like "Unknown command 'catalyst_ignore'", with no real obvious resolution mechanism.&lt;/p&gt;&lt;p&gt;I think this idea of automatic plugin discovery is starting to hit it's limits in terms of clarity.&lt;/p&gt;&lt;p&gt;And so I'd like to do something counter to my natural instincts here, and make M:I more verbose.&lt;/p&gt;&lt;p&gt;I'm thinking of something like the following for explicitly declaring the use of a non-core Module::Install extension.&lt;/p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;p&gt; &lt;tt&gt;use inc::Module::Install qw{ Catalyst XSUtil };&lt;/tt&gt;&lt;/p&gt;&lt;/div&gt; &lt;/blockquote&gt;&lt;p&gt;This would both allow M:I to error with a much more meaningful error when you don't have a plugin, and also prevent the loading of unused plugins which should prevent accidental plugin collisions (some of which I've seen occurring in the CPAN Testers machines).&lt;/p&gt;&lt;p&gt;Thoughts?&lt;/p&gt;</content>
    <category term="journal"/>
    <published>2010-09-06T02:26:06Z</published>
    <updated>2010-09-06T02:26:06Z</updated>
    <author>
      <name>Alias</name>
    </author>
    <id>tag:perlsphere.net,2006:http://use.perl.org/~Alias/journal/40523?from=rss</id>
  </entry>
  <entry>
    <title>Use branch reset grouping to number captures in alternations</title>
    <link rel="alternate" href="http://www.effectiveperlprogramming.com/blog/559" type="text/html"/>
    <summary type="text">Perl’s regular expressions have a simple rule for capturing groups. It
counts the order of left parentheses to assign capture variables. Not all
capture groups must actually match parts of the string, and Perl doesn’t
care if they do. Perl assigns capture groups inside an alternation
consecutively, even though it knows that only one branch of the
alternation will match. Perl 5.10 adds the branch reset, (?|alternation)
which mitigates that, though.

How many captures will a particular pattern produce? Can you tell just by
looking at the pattern? How much does the particular string matter? How
many capture groups are in this pattern:

(Buster)|(Mimi)|(Ella)

There are three capture groups. Only one of them is going to capture
because each group is in a different branch of the alternation. What
capture variables will that pattern set?

String

Triggered groups

$1

$2

$3

Buster

(Buster)

Buster

undef

undef

Mimi

(Mimi)

undef

Mimi

undef

Ella

(Ella)

undef

undef

Ella

Buster Mimi Ella

(Buster)

Buster

undef

undef

No matter which string you match against this pattern, you’ll also set at
least three of the capture variables, and two of those will be undefined.

Perl 5.10 introduces the branch reset pattern, (?|alternation). You use
that so that Perl numbers the capture buffers from the same starting
point for each branch in the alternation. Instead of creating three
capture buffers in your alternation, you can create just one buffer for
this pattern:

(?|(Buster)|(Mimi)|(Ella))

The three capture groups in this pattern populate the same buffer:

String

Triggered groups

$1

Buster

(Buster)

Buster

Mimi

(Mimi)

Mimi

Ella

(Ella)

Ella

Buster Mimi Ella

(Buster)

Buster

This is more important when the alternation is in the middle of a larger
pattern and there are additional capture groups after the alternation:

(?|(Buster)|(Mimi)|(Ella))(Ginger)

That’s a bit easier to read with extended patterns (Item XXX: XXX):

(?|             # $1
        (Buster) |
        (Mimi)   |
        (Ella)
)
(               # $2
        Ginger
)

No matter how many branches you add to the alternation, the group for
Ginger is always $2:

(?|             # $1
        (Buster) |
        (Mimi)   |
        (Ella)   |
        (Roscoe)
)
(               # $2
        Ginger
)

That doesn’t mean that the numbering after the alternation is always the
same
though. Not every branch must have the same number of captures, but the
pattern
reset grouping always takes up the number of buffers in the branch with
the
most capture groups even if that’s not the branch that matches. Consider
this
pattern where one of the branches has two capture groups:

(?|
        (Buster)       |  # $1, $2 is undef
        (Mimi)(Roscoe) |  # $1, $2
        (Ella)            # $1, $2 is undef
)
(                     # $3
        Ginger
)

String

Triggered groups

$1

BusterGinger

(Buster)

Buster

MimiRoscoeGinger

(Mimi)

Mimi

The branch reset can cause problems with named captures (XXX: XXX), which
are
really just aliases the the numbered captured variables. Labeling each
capture group doesn’t do what you might expect:

(?|
        (?Buster)              |  # $1, $2 is undef
        (?Mimi)(?Roscoe) |  # $1, $2
        (?Ella)                   # $1, $2 is undef
)
(?
        Ginger
)

Each label is just an alias to its numbered capture variable:

Label

Aliased to

cat1

$1

cat2

$1

cat3

$2

cat4

$1

cat5

$3

The labels don’t apply to the groups you think they do:

String

$1

$2

cat1

cat2

cat3

cat4

BusterGinger

Buster

undef

Buster

Buster

undef

Buster

EllaGinger

Ella

undef

Ella

Ella

undef

Ella

MimiRoscoeGinger

Mimi

Roscoe

Mimi

Mimi

Roscoe

Mimi

You should probably use the same labels in each branch and order them the
same so you get the results that you expect:

(?|
        (?&lt;cat1&gt;Buster)                 |  # $1, $2 is undef
        (?&lt;cat1&gt;Mimi)(?&lt;cat2&gt;Roscoe) |  # $1, $2
        (?&lt;cat1&gt;Ella)                      # $1, $2 is undef
)
(?&lt;cat3&gt;
        Ginger
)


Things to remember
------------------

  * Perl numbers capture groups by counting the literal order of left
    parentheses

  * Every capture group in an alternation creates a capture buffer

  * The pattern reset grouping, (?|...) restarts the buffer numbering for
    each branch of the alternation

  * Label captures in alternations with the same labels in the same order

Post to Twitter Post to Delicious Post to Digg Post to Facebook
Post to Reddit</summary>
    <content type="html">&lt;p&gt;Perl&amp;#8217;s regular expressions have a simple rule for capturing groups. It counts the order of left parentheses to assign capture variables. Not all capture groups must actually match parts of the string, and Perl doesn&amp;#8217;t care if they do. Perl assigns capture groups inside an alternation consecutively, even though it knows that only one branch of the alternation will match. Perl 5.10 adds the branch reset, &lt;code&gt;(?|alternation)&lt;/code&gt; which mitigates that, though.&lt;/p&gt;
&lt;p&gt;How many captures will a particular pattern produce? Can you tell just by looking at the pattern? How much does the particular string matter? How many capture groups are in this pattern:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
(Buster)|(Mimi)|(Ella)
&lt;/pre&gt;
&lt;p&gt;There are three capture groups. Only one of them is going to capture because each group is in a different branch of the alternation. What capture variables will that pattern set?&lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;String&lt;/th&gt;
&lt;th&gt;Triggered groups&lt;/th&gt;
&lt;th&gt;$1&lt;/th&gt;
&lt;th&gt;$2&lt;/th&gt;
&lt;th&gt;$3&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;td&gt;(Buster)&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;td&gt;(Mimi)&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ella&lt;/td&gt;
&lt;td&gt;(Ella)&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;Ella&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buster Mimi Ella&lt;/td&gt;
&lt;td&gt;(Buster)&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;No matter which string you match against this pattern, you&amp;#8217;ll also set at least three of the capture variables, and two of those will be undefined.&lt;/p&gt;
&lt;p&gt;Perl 5.10 introduces the &lt;i&gt;branch reset pattern&lt;/i&gt;, &lt;code&gt;(?|alternation)&lt;/code&gt;. You use that so that Perl numbers the capture buffers from the same starting point for each branch in the alternation. Instead of creating three capture buffers in your alternation, you can create just one buffer for this pattern: &lt;/p&gt;
&lt;pre class="brush:perl"&gt;
(?|(Buster)|(Mimi)|(Ella))
&lt;/pre&gt;
&lt;p&gt;The three capture groups in this pattern populate the same buffer:&lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;String&lt;/th&gt;
&lt;th&gt;Triggered groups&lt;/th&gt;
&lt;th&gt;$1&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;td&gt;(Buster)&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;td&gt;(Mimi)&lt;/td&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ella&lt;/td&gt;
&lt;td&gt;(Ella)&lt;/td&gt;
&lt;td&gt;Ella&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buster Mimi Ella&lt;/td&gt;
&lt;td&gt;(Buster)&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;This is more important when the alternation is in the middle of a larger pattern and there are additional capture groups after the alternation:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
(?|(Buster)|(Mimi)|(Ella))(Ginger)
&lt;/pre&gt;
&lt;p&gt;That&amp;#8217;s a bit easier to read with extended patterns (Item XXX: XXX):&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
(?|             # $1
	(Buster) |
	(Mimi)   |
	(Ella)
)
(               # $2
	Ginger
)
&lt;/pre&gt;
&lt;p&gt;No matter how many branches you add to the alternation, the group for &lt;code&gt;Ginger&lt;/code&gt; is always &lt;code&gt;$2&lt;/code&gt;:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
(?|             # $1
	(Buster) |
	(Mimi)   |
	(Ella)   |
	(Roscoe)
)
(               # $2
	Ginger
)
&lt;/pre&gt;
&lt;p&gt;That doesn&amp;#8217;t mean that the numbering after the alternation is always the same&lt;br /&gt;
though. Not every branch must have the same number of captures, but the pattern&lt;br /&gt;
reset grouping always takes up the number of buffers in the branch with the&lt;br /&gt;
most capture groups even if that&amp;#8217;s not the branch that matches. Consider this&lt;br /&gt;
pattern where one of the branches has two capture groups:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
(?|
	(Buster)       |  # $1, $2 is undef
	(Mimi)(Roscoe) |  # $1, $2
	(Ella)            # $1, $2 is undef
)
(                     # $3
	Ginger
)
&lt;/pre&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;String&lt;/th&gt;
&lt;th&gt;Triggered groups&lt;/th&gt;
&lt;th&gt;$1&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BusterGinger&lt;/td&gt;
&lt;td&gt;(Buster)&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MimiRoscoeGinger&lt;/td&gt;
&lt;td&gt;(Mimi)&lt;/td&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;The branch reset can cause problems with named captures (XXX: XXX), which are&lt;br /&gt;
really just aliases the the numbered captured variables. Labeling each capture group doesn&amp;#8217;t do what you might expect: &lt;/p&gt;
&lt;pre class="brush:perl"&gt;
(?|
	(?&lt;cat1&gt;Buster)              |  # $1, $2 is undef
	(?&lt;cat2&gt;Mimi)(?&lt;cat3&gt;Roscoe) |  # $1, $2
	(?&lt;cat4&gt;Ella)                   # $1, $2 is undef
)
(?&lt;cat5&gt;
	Ginger
)
&lt;/pre&gt;
&lt;p&gt;Each label is just an alias to its numbered capture variable:&lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;Label&lt;/th&gt;
&lt;th&gt;Aliased to&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cat1&lt;/td&gt;
&lt;td&gt;$1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cat2&lt;/td&gt;
&lt;td&gt;$1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cat3&lt;/td&gt;
&lt;td&gt;$2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cat4&lt;/td&gt;
&lt;td&gt;$1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cat5&lt;/td&gt;
&lt;td&gt;$3&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;The labels don&amp;#8217;t apply to the groups you think they do: &lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;String&lt;/th&gt;
&lt;th&gt;$1&lt;/th&gt;
&lt;th&gt;$2&lt;/th&gt;
&lt;th&gt;cat1&lt;/th&gt;
&lt;th&gt;cat2&lt;/th&gt;
&lt;th&gt;cat3&lt;/th&gt;
&lt;th&gt;cat4&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BusterGinger&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;Buster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EllaGinger&lt;/td&gt;
&lt;td&gt;Ella&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;Ella&lt;/td&gt;
&lt;td&gt;Ella&lt;/td&gt;
&lt;td&gt;undef&lt;/td&gt;
&lt;td&gt;Ella&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MimiRoscoeGinger&lt;/td&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;td&gt;Roscoe&lt;/td&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;td&gt;Roscoe&lt;/td&gt;
&lt;td&gt;Mimi&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;You should probably use the same labels in each branch and order them the same so you get the results that you expect:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
(?|
	(?&amp;lt;cat1&amp;gt;Buster)                 |  # $1, $2 is undef
	(?&amp;lt;cat1&amp;gt;Mimi)(?&amp;lt;cat2&amp;gt;Roscoe) |  # $1, $2
	(?&amp;lt;cat1&amp;gt;Ella)                      # $1, $2 is undef
)
(?&amp;lt;cat3&amp;gt;
	Ginger
)
&lt;/pre&gt;
&lt;h2&gt;Things to remember&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Perl numbers capture groups by counting the literal order of left parentheses
&lt;li&gt;Every capture group in an alternation creates a capture buffer
&lt;li&gt;The pattern reset grouping, &lt;code&gt;(?|...)&lt;/code&gt; restarts the buffer numbering for each branch of the alternation
&lt;li&gt;Label captures in alternations with the same labels in the same order
&lt;/ul&gt;
&lt;p align="left"&gt;&lt;a class="tt" href="http://twitter.com/home/?status=Use+branch+reset+grouping+to+number+captures+in+alternations+http://q4f79.th8.us" title="Post to Twitter"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-twitter2.png" alt="Post to Twitter"&gt;&lt;/a&gt; &lt;a class="tt" href="http://twitter.com/home/?status=Use+branch+reset+grouping+to+number+captures+in+alternations+http://q4f79.th8.us" title="Post to Twitter"&gt; &lt;/a&gt; &lt;a class="tt" href="http://delicious.com/post?url=http://www.effectiveperlprogramming.com/blog/559&amp;amp;title=Use+branch+reset+grouping+to+number+captures+in+alternations" title="Post to Delicious"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious"&gt;&lt;/a&gt; &lt;a class="tt" href="http://delicious.com/post?url=http://www.effectiveperlprogramming.com/blog/559&amp;amp;title=Use+branch+reset+grouping+to+number+captures+in+alternations" title="Post to Delicious"&gt; &lt;/a&gt; &lt;a class="tt" href="http://digg.com/submit?url=http://www.effectiveperlprogramming.com/blog/559&amp;amp;title=Use+branch+reset+grouping+to+number+captures+in+alternations" title="Post to Digg"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg"&gt;&lt;/a&gt; &lt;a class="tt" href="http://digg.com/submit?url=http://www.effectiveperlprogramming.com/blog/559&amp;amp;title=Use+branch+reset+grouping+to+number+captures+in+alternations" title="Post to Digg"&gt; &lt;/a&gt; &lt;a class="tt" href="http://www.facebook.com/share.php?u=http://www.effectiveperlprogramming.com/blog/559&amp;amp;t=Use+branch+reset+grouping+to+number+captures+in+alternations" title="Post to Facebook"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-facebook.png" alt="Post to Facebook"&gt;&lt;/a&gt; &lt;a class="tt" href="http://www.facebook.com/share.php?u=http://www.effectiveperlprogramming.com/blog/559&amp;amp;t=Use+branch+reset+grouping+to+number+captures+in+alternations" title="Post to Facebook"&gt; &lt;/a&gt; &lt;a class="tt" href="http://reddit.com/submit?url=http://www.effectiveperlprogramming.com/blog/559&amp;amp;title=Use+branch+reset+grouping+to+number+captures+in+alternations" title="Post to Reddit"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit"&gt;&lt;/a&gt; &lt;a class="tt" href="http://reddit.com/submit?url=http://www.effectiveperlprogramming.com/blog/559&amp;amp;title=Use+branch+reset+grouping+to+number+captures+in+alternations" title="Post to Reddit"&gt; &lt;/a&gt;&lt;/p&gt;</content>
    <category term="5.10 regular expressions"/>
    <published>2010-09-05T19:19:58Z</published>
    <updated>2010-09-05T19:19:58Z</updated>
    <author>
      <name>brian d foy</name>
    </author>
    <id>tag:perlsphere.net,2006:http://www.effectiveperlprogramming.com/?p=559</id>
  </entry>
  <entry>
    <title>CPAN Release Task::BeLike::JONASBN 1.01</title>
    <link rel="alternate" href="http://logiclab.org/wordpress/2010/09/05/cpan-release-taskbelikejonasbn-1-01/" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Task::BeLike::JONASBN 1.01 has been released to CPAN it is a simple bug
fix release.

Based on CPAN testers results I could see that after making the POD
generation a part of the build, I need to move the requirement for
Tie::IxHash to be asserted prior to the build. So the configuration phase
should identify the requirement for Tie::IxHash.

The distribution is using Tie::IxHash to create the POD documentation as
a part of the build process. This step is implemented as a step of it’s
own, but it has been integrated with the build action, simply so the step
is not forgotten.

My original idea was to have the list in Build.PL and the let the
CONTENTS section, be auto-generated. So Bundle::JONASBN and
Task::BeLike::JONASBN contain it’s own custom build system, based on a
sub class of Module::Build. The build system (Module::Build::Bundle) read
the requirements from Build.PL and inserts this in the CONTENTS section,
alphabetized.
I attempted to let the build system create beautiful POD, instead of the
standardized used in bundles. It took me several attempts to figure out
that it was the reason my particular bundle was not working as expected.
Bundles require some special magic on the client side to parse the
CONTENTS section, in this case primarily the CPAN client and the
requirements for developing a bundle are quite special and IMHO error
prone. It took me 4 releases to get it right, I was simply not grasping
the magic part.
Adam Kennedy at some point recognized this weakness in the tool chain and
introduced Task, a new much simpler approach. Task is based simply on
writing up the requirements in the build file, whether you use
Module::Build, ExtUtils::MakeMaker or Module::Install.
Tasks are easier to maintain and validate.
I was in that lucky position that I had put all my requirements in my
Build.PL since release 0.01. So when I choose to migrate to a Task based
approach it was just a matter of renaming packages etc.
Much of all my trouble was due to the fact that I had thought that the
approach would be the approach used in Task. But AFAIK it is a
combination of package name: Bundle:: and the CONTENTS section.
I have now migrated to the Task approach and reinstated the
beautification of the POD and everything works well and looks nice, well
apart from the little glitch with the order of assertions, but luckily
Module::Build handles the META file generation and the fix was fairly
simple.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml"><p>Task::BeLike::JONASBN 1.01 has been released to CPAN it is a simple bug fix release.</p>
<p>Based on CPAN testers <a href="http://www.cpantesters.org/distro/T/Task-BeLike-JONASBN.html?grade=1&amp;perlmat=2&amp;patches=2&amp;oncpan=2&amp;distmat=2&amp;perlver=ALL&amp;osname=ALL&amp;version=1.00">results</a> I could see that after making the POD generation a part of the build, I need to move the requirement for <a href="http://search.cpan.org/dist/Tie-IxHash/lib/Tie/IxHash.pm">Tie::IxHash</a> to be asserted prior to the build. So the configuration phase should identify the requirement for Tie::IxHash.</p>
<p>The distribution is using Tie::IxHash to create the POD documentation as a part of the build process. This step is implemented as a step of it’s own, but it has been integrated with the build action, simply so the step is not forgotten.</p>
<p>My original idea was to have the list in Build.PL and the let the CONTENTS section, be auto-generated. So Bundle::JONASBN and Task::BeLike::JONASBN contain it’s own custom build system, based on a sub class of <span><a href="http://search.cpan.org/dist/Module-Build/lib/Module/Build.pm">Module::Build</a></span>. The build system (<span>Module::Build::Bundle</span>) read the requirements from Build.PL and inserts this in the CONTENTS section, alphabetized.<br/>
I attempted to let the build system create <em>beautiful</em> POD, instead of the standardized used in bundles. It took me several attempts to figure out that it was the reason my particular bundle was not working as expected.<br/>
Bundles require some special <em>magic</em> on the client side to parse the CONTENTS section, in this case primarily the CPAN client and the requirements for developing a bundle are quite special and IMHO error prone. It took me 4 releases to get it right, I was simply not grasping the magic part.<br/>
Adam Kennedy at some point recognized this weakness in the tool chain and introduced <span><a href="http://search.cpan.org/dist/Task/lib/Task.pm">Task</a></span>, a new much simpler approach. <span><a href="http://search.cpan.org/dist/Task/lib/Task.pm">Task</a></span> is based simply on writing up the requirements in the build file, whether you use <span><a href="http://search.cpan.org/dist/Module-Build/lib/Module/Build.pm">Module::Build</a></span>, <span><a href="http://search.cpan.org/dist/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm">ExtUtils::MakeMaker</a></span> or <span><a href="http://search.cpan.org/dist/Module-Install/lib/Module/Install.pod">Module::Install</a></span>.<br/>
Tasks are easier to maintain and validate.<br/>
I was in that lucky position that I had put all my requirements in my Build.PL since release 0.01. So when I choose to migrate to a Task based approach it was just a matter of renaming packages etc.<br/>
Much of all my trouble was due to the fact that I had thought that the approach would be the approach used in <span><a href="http://search.cpan.org/dist/Task/lib/Task.pm">Task</a></span>. But AFAIK it is a combination of package name: Bundle:: and the CONTENTS section.<br/>
I have now migrated to the Task approach and reinstated the <em>beautification</em> of the POD and everything works well and looks nice, well apart from the little glitch with the order of assertions, but luckily Module::Build handles the META file generation and the fix was fairly simple.</p>
</div>
    </content>
    <category term="Releases cpan release task::belike::jonasbn Tie::IxHash"/>
    <published>2010-09-05T12:46:40Z</published>
    <updated>2010-09-05T12:46:40Z</updated>
    <author>
      <name>jonasbn</name>
    </author>
    <id>tag:perlsphere.net,2006:http://logiclab.org/wordpress/2010/09/05/cpan-release-taskbelikejonasbn-1-01/</id>
  </entry>
  <entry>
    <title>Fixing Perl5 Core Bugs: Report for Month 6</title>
    <link rel="alternate" href="http://news.perlfoundation.org/2010/09/fixing-perl5-core-bugs-report-3.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Dave Mitchell writes:

As per my grant conditions, here is a report for the August period.

I was mostly busy with other stuff this month, so didn't get to put in
many hours on the grant.

Over the first 25 weeks I have now averaged about 15 hours per week, less
than the nominal 20. I have used up approx 73% of the hours allocated to
the grant.

Report for period 2010/08/01 to 2010/08/31 inclusive

Summary

Effort (HH::MM):

  4:26 diagnosing bugs
  5:35 fixing bugs
  1:00 reviewing other people's bug fixes
  0:00 reviewing ticket histories
  6:45 review the ticket queue (triage)
  -----
  17:46 Total

Numbers of tickets closed:

  1 tickets closed that have been worked on
  0 tickets closed related to bugs that have been fixed
  0 tickets closed that were reviewed but not worked on (triage)
  -----
  1 Total

Short Detail

  5:35 [perl #58530] Bus error with constant + overload + stash
  manipulation + bless ]
  4:26 [perl #76872] perl debugger not working in taint mode
  1:00 [perl #77352] Memory leaks in threaded Perl (cloning PVGVs and
  PL_my_cxt_list)
  6:45 [TRIAGE]</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><em>Dave Mitchell writes:</em></p>

<p>As per my grant conditions, here is a report for the August period.</p>

<p>I was mostly busy with other stuff this month, so didn't get to put in many hours on the grant.</p>

<p>Over the first 25 weeks I have now averaged about 15 hours per week, less than the nominal 20. I have used up approx 73% of the hours allocated to the grant.</p>

<p>Report for period 2010/08/01 to 2010/08/31 inclusive</p>

<p><b>Summary</b></p>

<p>Effort (HH::MM):</p>

<blockquote><p>4:26 diagnosing bugs<br/>
5:35 fixing bugs<br/>
1:00 reviewing other people's bug fixes<br/>
0:00 reviewing ticket histories<br/>
6:45 review the ticket queue (triage)<br/>
-----<br/>
<b>17:46 Total</b></p></blockquote>

<p><b>Numbers of tickets closed:</b></p>

<blockquote><p>1 tickets closed that have been worked on<br/>
0 tickets closed related to bugs that have been fixed<br/>
0 tickets closed that were reviewed but not worked on (triage)<br/>
-----<br/>
1 Total</p></blockquote>


<p><b>Short Detail</b></p>

<blockquote><p>5:35 [perl #58530] Bus error with constant + overload + stash manipulation + bless ]<br/>
4:26 [perl #76872] perl debugger not working in taint mode<br/>
1:00 [perl #77352] Memory leaks in threaded Perl (cloning <span class="caps">PVGV</span>s and PL_my_cxt_list)<br/>
6:45 [TRIAGE]</p></blockquote>
        
    </div>
    </content>
    <category term="Grants grant perl5 booking"/>
    <published>2010-09-04T12:59:21Z</published>
    <updated>2010-09-04T12:59:21Z</updated>
    <author>
      <name>Karen</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:news.perlfoundation.org,2010://18.2712</id>
  </entry>
  <entry>
    <title>Less XS/More Ctypes</title>
    <link rel="alternate" href="http://www.modernperlbooks.com/mt/2010/09/less-xsmore-ctypes.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Perl is in better shape now than ever, but there's much left to improve.
(I wrote Five Features Perl 5 Needs Now almost two years ago, and four of
five are available in whole or in sufficient substitute, so that's great
progress.)

Rather than criticize Perl for what's going wrong (as if I were any
position to do so), I prefer to suggest new areas of improvement.

One of the biggest possible improvements to the world of Perl 5 is a
replacement for many cases of XS. Ryan Jdoubi's Ctypes for Perl was on my
original list, and it's still on my list.

Why is this important?

XS can be inscrutable. Try reading the documentation, spread out between
perlxstut and perlapi, with liberal use of the Cozens and Jenness book
Extending and Embedding Perl and, ultimately, trawling through—even
copying and pasting—chunks of the Perl 5 core which seems to do what you
want.

Now debug typemap problems, problems with contexts in threaded versus
unthreaded builds, and the vagaries of Makefile syntax across various
platforms, not to mention the joy of detecting whether you have the right
version of a shared library and its development headers on a version of
an operating system you've never seen, let alone used, and (oh yes)
Windows.

It's no wonder people want pure-Perl modules when possible.

It's also no wonder that, with all of the copying and pasting and reading
of the Perl 5 source code in lieu of a working, understandable example of
real-life XS code we can modify to our own purposes, far too many CPAN
modules and an unkonwn and scary amount of DarkPAN modules abuse the Perl
5 internals in such a way that upgrading to a newer version of Perl seems
like soul-swallowing black magic.

You try refactoring the internals sometime, then watch the black smoke
come in from the next monthly bleadperl release and sob softly as you put
back all of the mess and hope for the best.

If Perl 5's internals have much hope of refactoring and cleanup and
sanity, the less XS code the better. Ctypes for Perl can help by reducing
the need for XS. If most of the XS modules which are XS only because
there was previously no other obviously better way to pass data between
Perl and shared libraries, migrating them to Ctypes can remove the need
for XS. Improving the interface between Perl and C is much easier because
only Ctypes needs to change.

We won't entirely get rid of XS, but we can minimize its use to those
projects which really, really need it The fewer of those, the easier they
are to audit and review and port, if necessary.

The cleaner the internals of Perl 5 (and the better its extension
interfaces in sanity, cleanliness, safety, composability, and
documentation), the more possibilities for further development and
improvements.

(I also expect that modules which use Ctypes instead of XS will be
smaller, faster, easier to write, less memory hungry, and easier to
install and to redistribute.)</div>
    </summary>
    <content type="html">
        &lt;p&gt;&lt;a href="http://www.modernperlbooks.com/mt/2010/09/whats-going-right-in-perl.html"&gt;Perl is in better shape now than ever&lt;/a&gt;, but there's much left to improve.  (I wrote &lt;a href="http://perlmonks.org/?node_id=731526"&gt;Five Features Perl 5 Needs Now&lt;/a&gt; almost two years ago, and four of five are available in whole or in sufficient substitute, so that's great progress.)&lt;/p&gt;

&lt;p&gt;Rather than criticize Perl for what's going wrong (as if I were any position to do so), I prefer to suggest new areas of improvement.&lt;/p&gt;

&lt;p&gt;One of the biggest possible improvements to the world of Perl 5 is a replacement for many cases of XS.  Ryan Jdoubi's &lt;a href="http://gitorious.org/perl-ctypes"&gt;Ctypes for Perl&lt;/a&gt; was on my original list, and it's still on my list.&lt;/p&gt;

&lt;p&gt;Why is this important?&lt;/p&gt;

&lt;p&gt;XS can be inscrutable.  Try reading the documentation, spread out between &lt;a href="http://perldoc.perl.org/perlxstut.html"&gt;perlxstut&lt;/a&gt; and &lt;a href="http://perldoc.perl.org/perlapi.html"&gt;perlapi&lt;/a&gt;, with liberal use of
the Cozens and Jenness book &lt;a href="http://www.manning.com/jenness/"&gt;Extending
and Embedding Perl&lt;/a&gt; and, ultimately, trawling through&amp;mdash;even copying and
pasting&amp;mdash;chunks of the Perl 5 core which seems to do what you want.&lt;/p&gt;

&lt;p&gt;Now debug typemap problems, problems with contexts in threaded versus
unthreaded builds, and the vagaries of &lt;em&gt;Makefile&lt;/em&gt; syntax across various
platforms, not to mention the joy of detecting whether you have the right
version of a shared library and its development headers on a version of an
operating system you've never seen, let alone used, and (oh yes) Windows.&lt;/p&gt;

&lt;p&gt;It's no wonder people want pure-Perl modules when possible.&lt;/p&gt;

&lt;p&gt;It's also no wonder that, with all of the copying and pasting and reading of the Perl 5 source code in lieu of a working, understandable example of real-life XS code we can modify to our own purposes, far too many CPAN modules and an unkonwn and scary amount of DarkPAN modules abuse the Perl 5 internals in such a way that upgrading to a newer version of Perl seems like soul-swallowing black magic.&lt;/p&gt;

&lt;p&gt;You try refactoring the internals sometime, then watch the black smoke come
in from the next monthly bleadperl release and sob softly as you put back all
of the mess and hope for the best.&lt;/p&gt;

&lt;p&gt;If Perl 5's internals have much hope of refactoring and cleanup and sanity, the less XS code the better.  Ctypes for Perl can help by reducing the need for XS.  If most of the XS modules which are XS only because there was previously no other obviously better way to pass data between Perl and shared libraries, migrating them to Ctypes can remove the need for XS.  Improving the interface between Perl and C is much easier because only Ctypes needs to change.&lt;/p&gt;

&lt;p&gt;We won't entirely get rid of XS, but we can minimize its use to those
projects which really, really need it  The fewer of those, the easier they are
to audit and review and port, if necessary.&lt;/p&gt;

&lt;p&gt;The cleaner the internals of Perl 5 (and the better its extension interfaces
in sanity, cleanliness, safety, composability, and documentation), the more
possibilities for further development and improvements.&lt;/p&gt;

&lt;p&gt;(I also expect that modules which use Ctypes instead of XS will be smaller, faster, easier to write, less memory hungry, and easier to install and to redistribute.)&lt;/p&gt;

        
    </content>
    <category term="CPAN internals modern perl perl 5 xs"/>
    <published>2010-09-03T20:55:05Z</published>
    <updated>2010-09-03T20:55:05Z</updated>
    <author>
      <name>chromatic</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:www.modernperlbooks.com,2010:/mt//1.224</id>
  </entry>
  <entry>
    <title>Embeding Perl into C++ Applications - Update Report</title>
    <link rel="alternate" href="http://news.perlfoundation.org/2010/09/embeding-perl-into-c-applicati-2.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml"> Leon just sent an update on his grant:

  Past month I've been to YAPC::EU where I spoke about part of my
  project. I also used it to discuss some of the Windows related issues
  I ran into with others and they have helped me getting clear what's
  the problem. I haven't quite fixed it yet though. I also worked on
  refactoring and expanding the documentation, and fixed some
  bugreports (though one still open). I wanted to be finished with both
  points by September 1st, but due to some unexpected school
  obligations I haven't been able to do so. I've set myself a new
  deadline for October 1st.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        Leon just sent an update on his grant:<br/><br/><blockquote><i>Past month I've been to YAPC::EU where I spoke about part of my project. I also used it to discuss some of the Windows related issues I ran into with others and they have helped me getting clear what's the problem. I haven't quite fixed it yet though. I also worked on refactoring and expanding the documentation, and fixed some bugreports (though one still open). I wanted to be finished with both points by September 1st, but due to some unexpected school obligations I haven't been able to do so. I've set myself a new deadline for October 1st.</i><br/></blockquote>
        
    </div>
    </content>
    <category term="Grants grant-2008q4-embedding-perl-into-c++ grants"/>
    <published>2010-09-02T13:40:31Z</published>
    <updated>2010-09-02T13:40:31Z</updated>
    <author>
      <name>Alberto Simões</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:news.perlfoundation.org,2010://18.2710</id>
  </entry>
  <entry>
    <title>CPAN Major release: Bundle::JONASBN renamed and refactored to Task::BeLike::JONASBN</title>
    <link rel="alternate" href="http://logiclab.org/wordpress/2010/09/01/cpan-major-release-bundlejonasbn-renamed-and-refactored-to-taskbelikejonasbn/" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">The idea behind Bundles on CPAN is a very good. The implementation
however relies somewhat on magic in the client. Adam Kennedy’s Task
concept, solves this.

After reading the documentation and doing some considering I decided to
deprecate Bundle::JONASBN and then redo the same distribution as
Task::BeLike::JONASBN.

The project is in the same repository and Bundle::JONASBN was refactored
to support this and the project site was renamed also. Many of the
pointers are still using the internally used project key BJONASBN.

The Task concept is fairly easy and being a supporter of KISS, I am
thinking about using this concept for other things currently on the
drawing board.

Kudos should go to Adam Kennedy for the Task contribution to CPAN, it is
simply beautiful in all it’s simplicity.

Task::BeLike::JONASBN has been released to CPAN as version 1.00 making it
a major release on the same code base.

Task::BeLike::JONASBN and Bundle::JONASBN will live in parallel for an
amount of time, but Bundle::JONASBN will be removed from CPAN eventually
and all future development will be centered around Task::BeLike::JONASBN.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml"><p>The idea behind Bundles on CPAN is a very good. The implementation however relies somewhat on magic in the client. Adam Kennedy’s <a href="http://search.cpan.org/dist/Task/lib/Task.pm">Task</a> concept, solves this.</p>
<p>After reading the documentation and doing some considering I decided to deprecate Bundle::JONASBN and then redo the same distribution as Task::BeLike::JONASBN.</p>
<p>The project is in the same repository and Bundle::JONASBN was refactored to support this and the project site was renamed also. Many of the pointers are still using the internally used project key BJONASBN.</p>
<p>The Task concept is fairly easy and being a supporter of KISS, I am thinking about using this concept for other things currently on the drawing board.</p>
<p>Kudos should go to Adam Kennedy for the Task contribution to CPAN, it is simply beautiful in all it’s simplicity.</p>
<p>Task::BeLike::JONASBN has been released to CPAN as version 1.00 making it a major release on the same code base.</p>
<p>Task::BeLike::JONASBN and Bundle::JONASBN will live in parallel for an amount of time, but Bundle::JONASBN will be removed from CPAN eventually and all future development will be centered around Task::BeLike::JONASBN.</p>
</div>
    </content>
    <category term="Releases adamk bundle::jonasbn cpan deprecation kiss perl release task::belike::jonasbn"/>
    <published>2010-09-01T19:18:28Z</published>
    <updated>2010-09-01T19:18:28Z</updated>
    <author>
      <name>jonasbn</name>
    </author>
    <id>tag:perlsphere.net,2006:http://logiclab.org/wordpress/2010/09/01/cpan-major-release-bundlejonasbn-renamed-and-refactored-to-taskbelikejonasbn/</id>
  </entry>
  <entry>
    <title>What's Going Right in Perl</title>
    <link rel="alternate" href="http://www.modernperlbooks.com/mt/2010/09/whats-going-right-in-perl.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Eighteen months after I started this site, the Modern Perl book is almost
out, as is Using Perl 6. Perl 5.10.1, Perl 5.12.0, Perl 5.12.1, and (very
nearly) Perl 5.12.2 are out, with Perl 5.14 coming next spring (not month,
as I mistakenly typed). Spring means, of course, April or May 2011.
(Sorry, southern hemisphere; you should elect a volunteer release
manager.)

Rakudo Star has had two impressive releases, which brings Perl 6 to ever
more people. The Parrot VM had its 1.0 and 2.0 and 2.3 and 2.6 releases,
and if you want an order of magnitude performance improvement in Rakudo
Perl 6, the Parrot 3.0 series will deliver some impressive gains through
the Lorito reorganization.

I've spent a lot of time critiquing the Perl language and community and
even more time critiquing perceptions of Perl from within and without.
I'm glad to review what's going right. It's easy to make a list of great
new features of Perl and the community, but I can limit it to my
favorites, in terms of immediate and longer-term significance.

By no means are these the only important developments in Perl in the past
18 months; please by all means let us all know what you find most
important in your own journals and talks and presentations.

  * The revitalization of Perl 5 core development has amazed me. Regular
    monthly releases have become boring, as they should be. A rotating
    series of release managers helps avoid the burnout that's claimed
    every Perl 5 pumpking up to this point, and it helps to make the
    process of releasing a new stable version of Perl 5 easier. That's
    why you can have confidence upgrading to Perl 5.12.2 when it comes
    out, and why in a year Perl 5.10.1 will look old.

  * I've wanted Plack for Perl for ages; I've long thought Python's WSGI
    is a good example of the "There should be one obvious way to do it
    philosophy" (it works much better for interfaces to well-defined
    problem domains than language features). The rapid adoption of Plack
    for so many web frameworks and libraries within Perl—as well as the
    number of backends supported by Plack—has solved many of the
    deployment problems of Perl web applications. It also allows greater
    collaboration on middleware, such as debugging and profiling tools.

  * Ancillary tools such as perlbrew and cpanminus have demonstrated that
    very simple interfaces devoted to solving the most common problems
    can improve the user experience immensely. I've known how to maintain
    my own user- and app-specific Perl 5 installations for years, but
    I've never wanted to maintain the morass of symlinks necessary to do
    so. Now I don't have to. Similarly, cpanminus lets me install CPAN
    modules often in the time it takes the official CPAN client to
    download the indexes.

  * Regular releases of the first Perl 6 distribution (Rakudo Star)
    demonstrate the power and consistency and disruptive potential of
    Perl 6 to even more people. Every month brings new features and
    improvements. Every bug report and new module written and benchmark
    help the development community make it an even better platform for
    new projects.

  * Schwern made the CPAN forkable through gitPAN, and the world is
    better for it. Public distributed version control for Perl 5 improves
    the experience of submitting changes, and public distributed version
    control for CPAN distributions has helped me submit and publish more
    changes too. Noticing a typo in documentation on search.cpan.org has
    become almost an enjoyable experience, if I can find the appropriate
    repository on Github, fork it, make my changes, and submit a pull
    request within five minutes. Often I can.

I look forward to several other projects in the world of Perl, such as
Ryan Jendoubi's Ctypes for Perl 5 and the ongoing attempts in the Perl 5
core to rein in a sane set of functions for extensions to use. I've heard
that various help forums have become more helpful and less abusive
(especially #perl on irc.perl.org). I've even noticed a shift in how
community members talk about marketing, especially as the discussion has
changed from "Marketing? That's for those sick Java fans!" to "Hey, look
at all of the cool stuff we're doing with Perl!"

We can and should still make improvements, but if the past year and a
half is any guide, we can safely shift our cautious optimism for the
present and future of Perl to regular optimism.</div>
    </summary>
    <content type="html">
        &lt;p&gt;Eighteen months after I started this site, the &lt;a href="http://onyxneon.com/books/modern_perl/"&gt;Modern Perl book&lt;/a&gt; is almost out, as is &lt;a href="http://github.com/perl6/book"&gt;Using Perl 6&lt;/a&gt;.  Perl 5.10.1, Perl 5.12.0, Perl 5.12.1, and (very nearly) Perl 5.12.2 are out, with Perl 5.14 coming next spring (not &lt;em&gt;month&lt;/em&gt;, as I mistakenly typed).  Spring means, of course, April or May 2011.  (Sorry, southern hemisphere; you should elect a volunteer release manager.)&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.rakudo.org/"&gt;Rakudo Star&lt;/a&gt; has had two impressive releases, which brings Perl 6 to ever more people.  The &lt;a href="http://www.parrot.org"&gt;Parrot VM&lt;/a&gt; had its 1.0 and 2.0 and 2.3 and 2.6 releases, and if you want an order of magnitude performance improvement in Rakudo Perl 6, the Parrot 3.0 series will deliver some impressive gains through the &lt;a href="http://trac.parrot.org/parrot/wiki/Lorito"&gt;Lorito reorganization&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I've spent a lot of time critiquing the Perl language and community and even more time critiquing perceptions of Perl from within and without.  I'm glad to review what's going right.  It's easy to make a list of great new features of Perl and the community, but I can limit it to my favorites, in terms of immediate and longer-term significance.&lt;/p&gt;

&lt;p&gt;By no means are these the only important developments in Perl in the past 18 months; please by all means let us all know what &lt;em&gt;you&lt;/em&gt; find most important in your own journals and talks and presentations.&lt;/p&gt;

&lt;ul&gt;

&lt;li&gt;The revitalization of Perl 5 core development has amazed me.  &lt;a href="http://www.modernperlbooks.com/mt/2009/05/why-regular-releases-matter.html"&gt;Regular monthly releases have become boring&lt;/a&gt;, as they should be.  A rotating series of release managers helps avoid the burnout that's claimed every Perl 5 pumpking up to this point, and it helps to make the process of releasing a new stable version of Perl 5 easier.  That's why you can have confidence upgrading to Perl 5.12.2 when it comes out, and why in a year Perl 5.10.1 will look old.&lt;/li&gt;

&lt;li&gt;I've wanted &lt;a href="http://plackperl.org/"&gt;Plack&lt;/a&gt; for Perl for ages; I've long thought Python's WSGI is a good example of the "There should be one obvious way to do it philosophy" (it works much better for interfaces to well-defined problem domains than language features).  The rapid adoption of Plack for so many web frameworks and libraries within Perl&amp;mdash;as well as the number of backends supported by Plack&amp;mdash;has solved many of the deployment problems of Perl web applications.  It also allows greater collaboration on middleware, such as debugging and profiling tools.&lt;/li&gt;

&lt;li&gt;Ancillary tools such as &lt;a href="http://search.cpan.org/perldoc?App::perlbrew"&gt;perlbrew&lt;/a&gt; and &lt;a href="http://search.cpan.org/perldoc?App::cpanminus"&gt;cpanminus&lt;/a&gt; have demonstrated that very simple interfaces devoted to solving the most common problems can improve the user experience immensely.  I've known how to maintain my own user- and app-specific Perl 5 installations for years, but I've never wanted to maintain the morass of symlinks necessary to do so.  Now I don't have to.  Similarly, cpanminus lets me install CPAN modules often in the time it takes the official CPAN client to download the indexes.&lt;/li&gt;

&lt;li&gt;Regular releases of the first Perl 6 distribution (Rakudo Star) demonstrate the power and consistency and disruptive potential of Perl 6 to even more people.  Every month brings new features and improvements.  Every bug report and new module written and benchmark help the development community make it an even better platform for new projects.&lt;/li&gt;

&lt;li&gt;Schwern made the CPAN forkable through &lt;a href="http://github.com/gitpan"&gt;gitPAN&lt;/a&gt;, and the world is better for it.  Public distributed version control for Perl 5 improves the experience of submitting changes, and public distributed version control for CPAN distributions has helped me submit and publish more changes too.  Noticing a typo in documentation on search.cpan.org has become almost an enjoyable experience, if I can find the appropriate repository on Github, fork it, make my changes, and submit a pull request within five minutes.  Often I can.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;I look forward to several other projects in the world of Perl, such as Ryan Jendoubi's &lt;a href="http://gitorious.org/perl-ctypes"&gt;Ctypes for Perl 5&lt;/a&gt; and the ongoing attempts in the Perl 5 core to rein in a sane set of functions for extensions to use.  I've heard that various help forums have become more helpful and less abusive (especially &lt;code&gt;#perl&lt;/code&gt; on irc.perl.org).  I've even noticed a shift in how community members talk about marketing, especially as the discussion has changed from "Marketing?  That's for those sick Java fans!" to "Hey, look at all of the cool stuff we're doing with Perl!"&lt;/p&gt;

&lt;p&gt;We can and should still make improvements, but if the past year and a half is any guide, we can safely shift our cautious optimism for the present and future of Perl to regular optimism.&lt;/p&gt;
        
    </content>
    <category term="community marketing perl perl 5 perl 6"/>
    <published>2010-09-01T18:27:21Z</published>
    <updated>2010-09-01T18:27:21Z</updated>
    <author>
      <name>chromatic</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:www.modernperlbooks.com,2010:/mt//1.223</id>
  </entry>
  <entry>
    <title>CPAN Feature Release Business::DK::CVR 0.06 – OOP follow-up</title>
    <link rel="alternate" href="http://logiclab.org/wordpress/2010/09/01/cpan-feature-release-businessdkcvr-0-06-%e2%80%93-oop-follow-up/" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">The CPAN module Business::DK::CPR has followed it’s cousin
Business::DK::CVR and has been updated with an OOP implementation (see:
the earlier announcement).

Apart from the class addition, the release only addresses minor issues,
like a failing test case reported by CPAN-testers. POD has been updated
and the Build file has been adjusted.

The Changes file does not contain all the changes, it is lacking a
serious update so please refer to the project change log for details.

Source code is available from: http://logicLAB.jira.com/svn/BDKCPR/

Project homepage: http://logiclab.jira.com/browse/BDKCPR/

Wiki: http://logiclab.jira.com/wiki/display/BDKCPR/Home

Feedback and patches more than welcome,</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml"><p>The CPAN module <a href="http://search.cpan.org/dist/Business-DK-CPR/">Business::DK::CPR</a> has followed it’s cousin <a href="http://search.cpan.org/dist/Business-DK-CVR/">Business::DK::CVR</a> and has been updated with an OOP implementation (see: the earlier announcement).</p>
<p>Apart from the class addition, the release only addresses minor issues, like a failing test case reported by CPAN-testers. POD has been updated and the Build file has been adjusted.</p>
<p>The Changes file does not contain all the changes, it is lacking a serious update so please refer to the project <a href="http://logiclab.jira.com/browse/BDKCPR#selectedTab=com.atlassian.jira.plugin.system.project:changelog-panel">change log</a> for details.</p>
<p>Source code is available from: <a href="http://logicLAB.jira.com/svn/BDKCPR/">http://logicLAB.jira.com/svn/BDKCPR/</a></p>
<p>Project homepage: <a href="http://logiclab.jira.com/browse/BDKCPR/">http://logiclab.jira.com/browse/BDKCPR/</a></p>
<p>Wiki: <a href="http://logiclab.jira.com/wiki/display/BDKCPR/Home">http://logiclab.jira.com/wiki/display/BDKCPR/Home</a></p>
<p>Feedback and patches more than welcome,</p>
</div>
    </content>
    <category term="Releases cpan cpr oop perl release"/>
    <published>2010-09-01T09:45:44Z</published>
    <updated>2010-09-01T09:45:44Z</updated>
    <author>
      <name>jonasbn</name>
    </author>
    <id>tag:perlsphere.net,2006:http://logiclab.org/wordpress/2010/09/01/cpan-feature-release-businessdkcvr-0-06-%e2%80%93-oop-follow-up/</id>
  </entry>
  <entry>
    <title>Hague Grant Acceptance: Meta-model Improvements and Natively Typed Attributes</title>
    <link rel="alternate" href="http://news.perlfoundation.org/2010/09/hague-grant-acceptance-meta-mo.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I am pleased to announce that Jonathan Worthington's Hague Grant for
Meta-model Improvements and Natively Typed Attributes has been accepted.
Patrick Michaud has agreed to be the grant manager for this project.

I would like to thank everyone who provided feedback on this proposal.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I am pleased to announce that Jonathan Worthington's Hague Grant for <a href="http://news.perlfoundation.org/2010/07/hague-grant-application-meta-m.html">Meta-model Improvements and Natively Typed Attributes</a> has been accepted. Patrick Michaud has agreed to be the grant manager for this project.</p>

<p>I would like to thank everyone who provided feedback on this proposal.</p>
        
    </div>
    </content>
    <category term="Grants Hague"/>
    <published>2010-09-01T06:57:27Z</published>
    <updated>2010-09-01T06:57:27Z</updated>
    <author>
      <name>Karen</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:news.perlfoundation.org,2010://18.2708</id>
  </entry>
  <entry>
    <title>SDL 2.512 released - Layers Support added</title>
    <link rel="alternate" href="http://feedproxy.google.com/~r/YetAnotherPerlGameHackeryapgh/~3/Q5bESE5CTdc/sdl-2512-released-layers-support-added.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">The new release of SDL adds Layer support, which means that rendering
surfaces by layers is a lot easier. SDL 2.512 has several other changes
too. An experimental physics interface and minor fixes. Have a look at
the CHANGELOG.


Here is an implementation of the new Layer stuff. Solitaire.


[IMAGE]

[IMAGE]
[IMAGE]

[IMAGE]</div>
    </summary>
    <content type="text">The new release of SDL adds Layer support, which means that rendering surfaces by layers is a lot easier. SDL 2.512 has several other changes too. An experimental physics interface and minor fixes. Have a look at the CHANGELOG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is an implementation of the new Layer stuff. &lt;a href="http://github.com/froggs/Solitaire"&gt;Solitaire&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator"&gt;&lt;a href="http://www5.pic-upload.de/31.08.10/22z8bjleljol.jpg" imageanchor="1"&gt;&lt;img src="http://www5.pic-upload.de/31.08.10/22z8bjleljol.jpg"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img alt=""&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/n-w1Gixc0G4Uub3ttCs01KdM_E4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/n-w1Gixc0G4Uub3ttCs01KdM_E4/0/di"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/n-w1Gixc0G4Uub3ttCs01KdM_E4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/n-w1Gixc0G4Uub3ttCs01KdM_E4/1/di"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/YetAnotherPerlGameHackeryapgh/~4/Q5bESE5CTdc"&gt;</content>
    <category term="Game SDL EyeCandy Releases"/>
    <published>2010-08-31T15:09:00Z</published>
    <updated>2010-08-31T15:09:00Z</updated>
    <author>
      <name>Kartik</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:blogger.com,1999:blog-3102167581424744259.post-362786930729278631</id>
  </entry>
  <entry>
    <title>Testing that darned filehandle</title>
    <link rel="alternate" href="http://blogs.perl.org/users/ovid/2010/08/testing-that-darned-filehandle.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">It wasn't fun finding out that some legacy code creates a bunch of
filehandles on the fly to do logging.

package Some::Client;
use Some::Logging::Module;

# later ...
print MAGICLOGHANDLE $some_data;

That MAGICLOGHANDLE is dynamically generated and shoved into my namespace
(along with a ton of other handles, one per log). So I needed to test
what was being printed to it. Fortunately, Perl's dynamism makes this
really, really easy.

Here's the basics:

use Test::Class::Most parent =&gt; 'My::Test::Class';

use Some::Client;
use IO::Scalar;

sub logging : Tests {
    my $test = shift

    my $SH = IO::Scalar-&gt;new(\my $data);
    no warnings 'redefine';
    local *Some::Client::MAGICLOGHANDLE = $SH;

    # run a bunch of code
    like $data, qr/whateever should be in the log/,
        '... I love diddling namespaces;
}

Yup. It's just that easy to hijack a filehandle for my own nefarious
purposes.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>It wasn't fun finding out that some legacy code creates a bunch of filehandles on the fly to do logging.</p>

<pre><code>package Some::Client;
use Some::Logging::Module;

# later ...
print MAGICLOGHANDLE $some_data;
</code></pre>

<p>That MAGICLOGHANDLE is dynamically generated and shoved into my namespace (along with a ton of other handles, one per log).  So I needed to test what was being printed to it.  Fortunately, Perl's dynamism makes this really, really easy.</p>

        <p>Here's the basics:</p>

<pre><code>use Test::Class::Most parent =&gt; 'My::Test::Class';

use Some::Client;
use IO::Scalar;

sub logging : Tests {
    my $test = shift

    my $SH = IO::Scalar-&gt;new(\my $data);
    no warnings 'redefine';
    local *Some::Client::MAGICLOGHANDLE = $SH;

    # run a bunch of code
    like $data, qr/whateever should be in the log/,
        '... I love diddling namespaces;
}
</code></pre>

<p>Yup. It's just that easy to hijack a filehandle for my own nefarious purposes.</p>

    </div>
    </content>
    <category term="testing tests"/>
    <published>2010-08-31T13:14:09Z</published>
    <updated>2010-08-31T13:14:09Z</updated>
    <author>
      <name>Ovid</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:blogs.perl.org,2010:/users/ovid//11.960</id>
  </entry>
  <entry>
    <title>Perl Compiler Speed – It’s Fast!</title>
    <link rel="alternate" href="http://curiousprogrammer.wordpress.com/2010/08/31/perl-compiler-speed-its-fast/" type="text/html"/>
    <summary type="text">As a developer who is not responsible for many infrastructure modules, I
shouldn’t really waste so much of time micro-benchmarking. Profiling my
code after the fact should be sufficient if even that is necessary.

But it seems I’ve got into a bad habit.

------------------------------------------------------------------------

I’m not the only person that thinks that MooseX loading all those
pre-requisites is what is taking a lot of time. Dave Rolsky says in the
latest Moose blog post:

What’s a bit sad, however, is that this only appears to save 6-10% of the
compilation time in real usage. I’m not sure why that is, but I think the
issue is that the perl core’s compilation time may be a big factor. As I
said, loading that one Markdent modules loads a lot of modules (203
individual .pm files), and the raw overhead of simply reading all those
files and compiling them may be a significant chunk of the compilation
time.

That gets me thinking about the speed of the perl compilation step.
Although using eval doesn’t have the same disk IO as use, it still
exercises the compiler.


Loop Unrolling with Eval

Does anyone remember back in the day when we used to unroll loops? For
example, if we had an instruction sequence that was do_something, add,
jne and do_something was relatively short, you could save some time
unrolling that to do_something, add, do_something, add, jne – you would
only have to execute approximately half as many jne instructions across a
loop lifetime.

That is something I never worry about in perl. Unless I have to come up
with contrived examples for my blog.

sub eval_loop{
    my $count = 0;
    my $s = '';
    for (my $i = 0; $i &lt; 100_000; ++$i) {
        $s .= '$count += ' . $i . ";\n";
    }
    eval $s;
    $count;
}
sub vanilla_loop{
    my $count = 0;
    for (my $i = 0; $i &lt; 100_000; ++$i) {
        $count += $i;
    }
    $count;
}
my $code = '';for (my $i = 0; $i &lt; 100_000; ++$i) {
    $code .= '$count += ' . $i . ";\n";
}

$code = '
sub totally_unrolled {
    my $count = 0;' . "\n" . $code . '
    $count;
};';
eval $code;

eval_loop compiles the unrolled loop every time the subroutine is called
whereas totally_unrolled is compiled prior to benchmarking.

I also wanted some partially unrolled loops for comparison sake.
Obviously these examples are not suitable for production use. For
example, consider what would happen if unrolled_loop_4 needed to execute
a number of times that was not a multiple of 4.

sub unrolled_loop_2{
    my $count = 0;
    for (my $i = 0; $i &lt; 100_000; ++$i) {
        $count += $i;
        $count += ++$i;
    }
    $count;
}
sub unrolled_loop_4{
    my $count = 0;
    for (my $i = 0; $i &lt; 100_000; ++$i) {
        $count += $i;
        $count += ++$i;
        $count += ++$i;
        $count += ++$i;
    }
    $count;
}


Benchmarking

The full benchmarking code is as follows. I test the result of each
function to ensure I’m getting the same answer.

use Benchmark qw(:hireswallclock);
use strict;use warnings;
sub vanilla_loop{
    my $count = 0;
    for (my $i = 0; $i &lt; 100_000; ++$i) {
        $count += $i;
    }
    $count;
}
sub unrolled_loop_2{
    my $count = 0;
    for (my $i = 0; $i &lt; 100_000; ++$i) {
        $count += $i;
        $count += ++$i;
    }
    $count;
}
sub unrolled_loop_4{
    my $count = 0;
    for (my $i = 0; $i &lt; 100_000; ++$i) {
        $count += $i;
        $count += ++$i;
        $count += ++$i;
        $count += ++$i;
    }
    $count;
}
sub eval_loop{
    my $count = 0;
    my $s = '';
    for (my $i = 0; $i &lt; 100_000; ++$i) {
        $s .= '$count += ' . $i . ";\n";
    }
    eval $s;
    $count;
}
my $code = '';for (my $i = 0; $i &lt; 100_000; ++$i) {
    $code .= '$count += ' . $i . ";\n";
}

$code = '
sub totally_unrolled {
    my $count = 0;' . "\n" . $code . '
    $count;
};';
eval $code;
print vanilla_loop(), "\n";print unrolled_loop_2(), "\n";print unrolled_loop_4(), "\n";print eval_loop(), "\n";print totally_unrolled(), "\n";

Benchmark::cmpthese(-1, {
    'vanilla' =&gt; \&amp;vanilla_loop,
    'unrolled-2' =&gt; \&amp;unrolled_loop_2,
    'unrolled-4' =&gt; \&amp;unrolled_loop_4,
    'eval' =&gt; \&amp;eval_loop,
    'unrolled-max' =&gt; \&amp;totally_unrolled,
});

And the results are:

$ perl unrolling.pl
4999950000
4999950000
4999950000
4999950000
4999950000
               Rate        eval  unrolled-2  unrolled-4     vanilla unrolled-max
eval         3.25/s          --        -93%        -95%        -95%         -96%
unrolled-2   48.1/s       1381%          --        -25%        -26%         -45%
unrolled-4   63.9/s       1865%         33%          --         -2%         -27%
vanilla      65.1/s       1902%         35%          2%          --         -26%
unrolled-max 87.7/s       2598%         82%         37%         35%           --


Conclusions

I am actually surprised that eval is as fast as it is. It runs less than
20 times slower than the vanilla loop, yet it has to construct a string
by appending to it 100,000 times and run the compiler on the result. Or
to put it another way, it compiles and runs 100,000 lines of code in
under a third of a second. Good job perl compiler guys! Or did you put
something in there for patholgically ridiculous examples like this?

And I was right never to worry about unrolling my loops. unrolled-2 is
quite significantly slower than vanilla. As I can’t think of any good
reason for that, it makes me worried that I’ve done something wrong.

Even fully unrolling the loop, which is quite ridiculous gives me a
relatively tiny 35% speed increase.

------------------------------------------------------------------------

Related posts:

  * Benchmarking Perl Subroutine Calls

  * More Subroutine Benchmarking

  * Spurious Benchmark.pm Warnings


Filed under: Perl Tagged: benchmarking</summary>
    <content type="html">&lt;p&gt;As a developer who is not responsible for many &lt;em&gt;infrastructure modules&lt;/em&gt;, I shouldn&amp;#8217;t really waste so much of time micro-benchmarking.  Profiling my code after the fact should be sufficient if even that is necessary.&lt;/p&gt;
&lt;p&gt;But it seems I&amp;#8217;ve got into a bad habit.&lt;/p&gt;
&lt;hr /&gt;
&lt;p class="first"&gt;I&amp;#8217;m not the only person that thinks that MooseX loading all those pre-requisites is what is &lt;a href="http://curiousprogrammer.wordpress.com/2010/08/19/benchmarking-measuring-the-right-thing"&gt;taking a lot of time&lt;/a&gt;.  Dave Rolsky says in the &lt;a href="http://blog.moose.perl.org/2010/08/moose-110-and-classmop-105-now-compiling-10-faster.html"&gt;latest Moose blog post&lt;/a&gt;:&lt;/p&gt;
&lt;div&gt;&lt;em&gt;What&amp;#8217;s a bit sad, however, is that this only appears to save 6-10% of the compilation time in real usage. I&amp;#8217;m not sure why that is, but I think the issue is that the perl core&amp;#8217;s compilation time may be a big factor. As I said, loading that one Markdent modules loads a lot  of modules (203 individual .pm files), and the raw overhead of &lt;strong&gt;simply reading all those files and compiling them&lt;/strong&gt; may be a significant chunk of the compilation time.&lt;/em&gt;&lt;/div&gt;
&lt;p&gt;That gets me thinking about the speed of the perl compilation step.  Although using eval doesn&amp;#8217;t have the same disk IO as &lt;code&gt;use&lt;/code&gt;, it still exercises the compiler.&lt;/p&gt;
&lt;h3&gt;Loop Unrolling with Eval&lt;/h3&gt;
&lt;p class="first"&gt;Does anyone remember back in the day when we used to unroll loops?  For example, if we had an instruction sequence that was do_something, add, jne and do_something was relatively short, you could save some time unrolling that to do_something, add, do_something, add, jne &amp;#8211; you would only have to execute approximately half as many jne instructions across a loop lifetime.&lt;/p&gt;
&lt;p&gt;That is something I never worry about in perl.  Unless I have to come up with contrived examples for my blog.&lt;/p&gt;
&lt;pre&gt;
&lt;span&gt;sub&lt;/span&gt; &lt;span&gt;eval_loop&lt;/span&gt;
{
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$count&lt;/span&gt; = 0;
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$s&lt;/span&gt; = &lt;span&gt;''&lt;/span&gt;;
    &lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
        $s .= &lt;span&gt;'$count += '&lt;/span&gt; . $i . &lt;span&gt;";\n"&lt;/span&gt;;
    }
    &lt;span&gt;eval&lt;/span&gt; $s;
    $count;
}

&lt;span&gt;sub&lt;/span&gt; &lt;span&gt;vanilla_loop&lt;/span&gt;
{
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$count&lt;/span&gt; = 0;
    &lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
        $count += $i;
    }
    $count;
}

&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$code&lt;/span&gt; = &lt;span&gt;''&lt;/span&gt;;
&lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
    $code .= &lt;span&gt;'$count += '&lt;/span&gt; . $i . &lt;span&gt;";\n"&lt;/span&gt;;
}

$code = &lt;span&gt;'
sub totally_unrolled {
    my $count = 0;'&lt;/span&gt; . &lt;span&gt;"\n"&lt;/span&gt; . $code . &lt;span&gt;'
    $count;
};'&lt;/span&gt;;

&lt;span&gt;eval&lt;/span&gt; $code;
&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;eval_loop&lt;/code&gt; compiles the unrolled loop every time the subroutine is called whereas &lt;code&gt;totally_unrolled&lt;/code&gt; is compiled prior to benchmarking.&lt;/p&gt;
&lt;p&gt;I also wanted some partially unrolled loops for comparison sake.  Obviously these examples are not suitable for production use.  For example, consider what would happen if unrolled_loop_4 needed to execute a number of times that was not a multiple of 4.&lt;/p&gt;
&lt;pre&gt;
&lt;span&gt;sub&lt;/span&gt; &lt;span&gt;unrolled_loop_2&lt;/span&gt;
{
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$count&lt;/span&gt; = 0;
    &lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
        $count += $i;
        $count += ++$i;
    }
    $count;
}

&lt;span&gt;sub&lt;/span&gt; &lt;span&gt;unrolled_loop_4&lt;/span&gt;
{
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$count&lt;/span&gt; = 0;
    &lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
        $count += $i;
        $count += ++$i;
        $count += ++$i;
        $count += ++$i;
    }
    $count;
}
&lt;/pre&gt;
&lt;h3&gt;Benchmarking&lt;/h3&gt;
&lt;p class="first"&gt;The full benchmarking code is as follows.  I test the result of each function to ensure I&amp;#8217;m getting the same answer.&lt;/p&gt;
&lt;pre&gt;
&lt;span&gt;use&lt;/span&gt; &lt;span&gt;Benchmark&lt;/span&gt; &lt;span&gt;qw&lt;/span&gt;(:hireswallclock);

&lt;span&gt;use&lt;/span&gt; &lt;span&gt;strict&lt;/span&gt;;
&lt;span&gt;use&lt;/span&gt; &lt;span&gt;warnings&lt;/span&gt;;

&lt;span&gt;sub&lt;/span&gt; &lt;span&gt;vanilla_loop&lt;/span&gt;
{
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$count&lt;/span&gt; = 0;
    &lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
        $count += $i;
    }
    $count;
}

&lt;span&gt;sub&lt;/span&gt; &lt;span&gt;unrolled_loop_2&lt;/span&gt;
{
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$count&lt;/span&gt; = 0;
    &lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
        $count += $i;
        $count += ++$i;
    }
    $count;
}

&lt;span&gt;sub&lt;/span&gt; &lt;span&gt;unrolled_loop_4&lt;/span&gt;
{
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$count&lt;/span&gt; = 0;
    &lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
        $count += $i;
        $count += ++$i;
        $count += ++$i;
        $count += ++$i;
    }
    $count;
}

&lt;span&gt;sub&lt;/span&gt; &lt;span&gt;eval_loop&lt;/span&gt;
{
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$count&lt;/span&gt; = 0;
    &lt;span&gt;my&lt;/span&gt; &lt;span&gt;$s&lt;/span&gt; = &lt;span&gt;''&lt;/span&gt;;
    &lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
        $s .= &lt;span&gt;'$count += '&lt;/span&gt; . $i . &lt;span&gt;";\n"&lt;/span&gt;;
    }
    &lt;span&gt;eval&lt;/span&gt; $s;
    $count;
}

&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$code&lt;/span&gt; = &lt;span&gt;''&lt;/span&gt;;
&lt;span&gt;for&lt;/span&gt; (&lt;span&gt;my&lt;/span&gt; &lt;span&gt;$i&lt;/span&gt; = 0; $i &amp;lt; 100_000; ++$i) {
    $code .= &lt;span&gt;'$count += '&lt;/span&gt; . $i . &lt;span&gt;";\n"&lt;/span&gt;;
}

$code = &lt;span&gt;'
sub totally_unrolled {
    my $count = 0;'&lt;/span&gt; . &lt;span&gt;"\n"&lt;/span&gt; . $code . &lt;span&gt;'
    $count;
};'&lt;/span&gt;;

&lt;span&gt;eval&lt;/span&gt; $code;

&lt;span&gt;print&lt;/span&gt; vanilla_loop(), &lt;span&gt;"\n"&lt;/span&gt;;
&lt;span&gt;print&lt;/span&gt; unrolled_loop_2(), &lt;span&gt;"\n"&lt;/span&gt;;
&lt;span&gt;print&lt;/span&gt; unrolled_loop_4(), &lt;span&gt;"\n"&lt;/span&gt;;
&lt;span&gt;print&lt;/span&gt; eval_loop(), &lt;span&gt;"\n"&lt;/span&gt;;
&lt;span&gt;print&lt;/span&gt; totally_unrolled(), &lt;span&gt;"\n"&lt;/span&gt;;

Benchmark::cmpthese(-1, {
    &lt;span&gt;'vanilla'&lt;/span&gt; =&amp;gt; \&amp;amp;vanilla_loop,
    &lt;span&gt;'unrolled-2'&lt;/span&gt; =&amp;gt; \&amp;amp;unrolled_loop_2,
    &lt;span&gt;'unrolled-4'&lt;/span&gt; =&amp;gt; \&amp;amp;unrolled_loop_4,
    &lt;span&gt;'eval'&lt;/span&gt; =&amp;gt; \&amp;amp;eval_loop,
    &lt;span&gt;'unrolled-max'&lt;/span&gt; =&amp;gt; \&amp;amp;totally_unrolled,
});
&lt;/pre&gt;
&lt;p&gt;And the results are:&lt;/p&gt;
&lt;pre&gt;
$ perl unrolling.pl
4999950000
4999950000
4999950000
4999950000
4999950000
               Rate        eval  unrolled-2  unrolled-4     vanilla unrolled-max
eval         3.25/s          --        -93%        -95%        -95%         -96%
unrolled-2   48.1/s       1381%          --        -25%        -26%         -45%
unrolled-4   63.9/s       1865%         33%          --         -2%         -27%
vanilla      65.1/s       1902%         35%          2%          --         -26%
unrolled-max 87.7/s       2598%         82%         37%         35%           --
&lt;/pre&gt;
&lt;h3&gt;Conclusions&lt;/h3&gt;
&lt;p class="first"&gt;I am actually surprised that eval is as fast as it is.  It runs less than 20 times slower than the vanilla loop, yet it has to construct a string by appending to it 100,000 times and run the compiler on the result.  Or to put it another way, it compiles &lt;em&gt;and runs&lt;/em&gt; 100,000 lines of code in under a third of a second.  Good job perl compiler guys!  Or did you put something in there for patholgically ridiculous examples like this?&lt;/p&gt;
&lt;p&gt;And I was right never to worry about unrolling my loops.  unrolled-2 is quite significantly slower than vanilla.  As I can&amp;#8217;t think of any good reason for that, it makes me worried that I&amp;#8217;ve done something wrong.&lt;/p&gt;
&lt;p&gt;Even fully unrolling the loop, which is quite ridiculous gives me a relatively tiny 35% speed increase.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;strong&gt;Related posts:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://curiousprogrammer.wordpress.com/2010/06/21/benchmarking-perl-subroutine-calls/"&gt;Benchmarking Perl Subroutine Calls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://curiousprogrammer.wordpress.com/2010/06/24/more-subroutine-benchmarking/"&gt;More Subroutine Benchmarking&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://curiousprogrammer.wordpress.com/2010/08/25/spurious-benchmark-pm-warnings/"&gt;Spurious Benchmark.pm Warnings&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;Filed under: &lt;a href="http://curiousprogrammer.wordpress.com/category/programming/perl-programming/"&gt;Perl&lt;/a&gt; Tagged: &lt;a href="http://curiousprogrammer.wordpress.com/tag/benchmarking/"&gt;benchmarking&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/curiousprogrammer.wordpress.com/1245/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/comments/curiousprogrammer.wordpress.com/1245/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/curiousprogrammer.wordpress.com/1245/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/delicious/curiousprogrammer.wordpress.com/1245/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/curiousprogrammer.wordpress.com/1245/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/facebook/curiousprogrammer.wordpress.com/1245/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/curiousprogrammer.wordpress.com/1245/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/twitter/curiousprogrammer.wordpress.com/1245/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/curiousprogrammer.wordpress.com/1245/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/stumble/curiousprogrammer.wordpress.com/1245/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/curiousprogrammer.wordpress.com/1245/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/digg/curiousprogrammer.wordpress.com/1245/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/curiousprogrammer.wordpress.com/1245/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/reddit/curiousprogrammer.wordpress.com/1245/"&gt;&lt;/a&gt; &lt;img alt="" src="http://stats.wordpress.com/b.gif?host=curiousprogrammer.wordpress.com&amp;amp;blog=367204&amp;amp;post=1245&amp;amp;subd=curiousprogrammer&amp;amp;ref=&amp;amp;feed=1"&gt;</content>
    <category term="Perl benchmarking"/>
    <published>2010-08-31T05:00:02Z</published>
    <updated>2010-08-31T05:00:02Z</updated>
    <author>
      <name>Jared</name>
    </author>
    <id>tag:perlsphere.net,2006:http://curiousprogrammer.wordpress.com/?p=1245</id>
    <link xmlns="http://purl.org/atom/ns#" rel="enclosure" type="" href="" length=""/>
  </entry>
  <entry>
    <title>How to script git with perl and Git::Wrapper</title>
    <link rel="alternate" href="http://www.dagolden.com/index.php/998/how-to-script-git-with-perl-and-gitwrapper/" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">If you work with git, eventually you will want to script something that
git doesn't do already and can't be accomplished with an alias. If you
use Perl, the Git::Wrapper module makes scripting git easy.

The big advantage of Git::Wrapper is that it wraps the binary version of
git, which keeps your perl and git independent. Upgrade perl and not git?
Add Git::Wrapper and you're done. Upgrade git while keeping your existing
perl? No problem. If you get your git from an OS distribution package,
but roll your own perl, then Git::Wrapper is for you!

Git::Wrapper just makes it really easy to pass git commands and get back
useful data. It really shines on "git log" commands, as it parses each
commit message into Git::Wrapper::Log objects with accessors for id,
author, date, and message. For everything else, it's not much more than a
wrapper around qx(), but it returns arrays of lines and throws exceptions
when things go wrong, which just saves a little time and code.

Here is a short example that I whipped up recently to automate the
process of adding a github repository remote for someone when they send
me a pull request. (It also uses my Getopt::Lucid module, but as the name
suggests, it should be clear what that does.)

#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use autodie;
use Git::Wrapper;
use Getopt::Lucid qw/:all/;

# USAGE: github-remote [-r REPO] [NAME]
#     NAME -- a github user name (or defaults to 'dagolden')
#     REPO -- a github repository path (or is parsed out of my private origin repo)

my $opts = Getopt::Lucid-&gt;getopt([
  Param('repo|r'),
]);

my $who = shift @ARGV;

# Get a wrapper for the current directory
my $git = Git::Wrapper-&gt;new(".");

# Locate the origin repository URL
my ($origin) = grep { /origin/ } $git-&gt;remote("-v");
die "Couldn't determine origin\n" unless $origin;
$origin =~ s/^origin\s+//;
$origin =~ s/\s+\(.*$//;

# Parse out the repository path
my $repo = $opts-&gt;get_repo;
unless ( $repo ) {
  # me@git.example.com:my-repo-name.git
  ($repo) = $origin =~ m/^[^:]+:(.+)$/;
}

# Set up someone else's github repo
if ( $who ) {
  $git-&gt;remote("add", $who, "git://github.com/${who}/${repo}");
}
# Or set up my own github mirror
else {
  $git-&gt;remote("add", "github", "git\@github.com:dagolden/${repo}");
}

That's it. I admit the program is a little crufty because of how I manage
my repositories with a private origin that I mirror to a github
repository, but there's almost no cruft around interactions with git.
Consider this:

  $git-&gt;remote("add", $who, "git://github.com/${who}/${repo}");

If the command fails (if there's already $who as a remote name), an
exception will be thrown. That means I don't have to write any error
handling myself, which is perfect for a simple automation program like
this one.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml"><p>If you work with <a href="http://git-scm.com/">git</a>, eventually you will want to script something that git doesn't do already and can't be accomplished with an alias.  If you use <a href="http://perl.org/">Perl</a>, the <a href="http://p3rl.org/Git::Wrapper">Git::Wrapper</a> module makes scripting git easy.</p>
<p>The big advantage of Git::Wrapper is that it wraps the binary version of git, which keeps your perl and git independent.  Upgrade perl and not git?  Add Git::Wrapper and you're done.  Upgrade git while keeping your existing perl?  No problem.  If you get your git from an OS distribution package, but <a href="http://p3rl.org/App::perlbrew">roll your own perl</a>, then Git::Wrapper is for you!</p>
<p>Git::Wrapper just makes it really easy to pass git commands and get back useful data.  It really shines on "git log" commands, as it parses each commit message into Git::Wrapper::Log objects with accessors for id, author, date, and message.  For everything else, it's not much more than a wrapper around qx(), but it returns arrays of lines and throws exceptions when things go wrong, which just saves a little time and code.</p>
<p>Here is a short example that I whipped up recently to automate the process of adding a <a href="http://github.com/">github</a> repository remote for someone when they send me a pull request.  (It also uses my <a href="http://p3rl.org/Getopt::Lucid">Getopt::Lucid</a> module, but as the name suggests, it should be clear what that does.)</p>
<pre class="brush: perl;">
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use autodie;
use Git::Wrapper;
use Getopt::Lucid qw/:all/;

# USAGE: github-remote [-r REPO] [NAME]
#     NAME -- a github user name (or defaults to 'dagolden')
#     REPO -- a github repository path (or is parsed out of my private origin repo)

my $opts = Getopt::Lucid-&gt;getopt([
  Param('repo|r'),
]);

my $who = shift @ARGV;

# Get a wrapper for the current directory
my $git = Git::Wrapper-&gt;new(".");

# Locate the origin repository URL
my ($origin) = grep { /origin/ } $git-&gt;remote("-v");
die "Couldn't determine origin\n" unless $origin;
$origin =~ s/^origin\s+//;
$origin =~ s/\s+\(.*$//;

# Parse out the repository path
my $repo = $opts-&gt;get_repo;
unless ( $repo ) {
  # me@git.example.com:my-repo-name.git
  ($repo) = $origin =~ m/^[^:]+:(.+)$/;
}

# Set up someone else's github repo
if ( $who ) {
  $git-&gt;remote("add", $who, "git://github.com/${who}/${repo}");
}
# Or set up my own github mirror
else {
  $git-&gt;remote("add", "github", "git\@github.com:dagolden/${repo}");
}
</pre>
<p>That's it.  I admit the program is a little crufty because of how I manage my repositories with a private origin that I mirror to a github repository, but there's almost no cruft around interactions with git.  Consider this:</p>
<pre class="brush: perl;">
  $git-&gt;remote("add", $who, "git://github.com/${who}/${repo}");
</pre>
<p>If the command fails (if there's already $who as a remote name), an exception will be thrown. That means I don't have to write any error handling myself, which is perfect for a simple automation program like this one.</p>
</div>
    </content>
    <category term="Uncategorized git perl-programming ironman"/>
    <published>2010-08-31T03:17:41Z</published>
    <updated>2010-08-31T03:17:41Z</updated>
    <author>
      <name>dagolden</name>
    </author>
    <id>tag:perlsphere.net,2006:http://www.dagolden.com/?p=998</id>
  </entry>
  <entry>
    <title>given/when – the Perl switch statement</title>
    <link rel="alternate" href="http://transfixedbutnotdead.com/2010/08/30/givenwhen-the-perl-switch-statement/" type="text/html"/>
    <summary type="text">Its been a while since my last post; summer holidays have inflicted upon
me some big distractions! So to ease myself back in gently I’ll I’ve
pulled out a (nearly finished but unposted) article from last year (in
true Blue Peter tradition!)

This post was inspired by this nice &amp; straightforward blog article: How A
Ruby Case Statement Works And What You Can Do With It. I’ve simply
converted the Ruby code to Perl and added some so called insightful notes
:)

Now what Ruby calls case/when statements is more commonly known in
computer parlance has the switch statement.

Perl itself has had such a switch statement for quite a while now:

use Switch;

switch ($grade) {
    case "A"   { say "Well done!" }
    case "B"   { say "Try harder!" }
    case "C"   { say "You need help!!!" }
    else         { print "You just making it up" }
}

However DON’T USE IT!!! Its a source filter and is being deprecated.

Instead use given/when which is the Perl 6 switch statement that was
introduced at perl 5.10.

use strict;
use warnings;
use feature qw(switch say);

print 'Enter your grade: ';
chomp( my $grade = &lt;&gt; );

given ($grade) {
    when ('A') { say 'Well done!'       }
    when ('B') { say 'Try harder!'      }
    when ('C') { say 'You need help!!!' }
    default { say 'You are just making it up!' }
}

And at perl 5.12 you could also use when has a statement modifiers:

use 5.012;
use warnings;

print 'Enter your grade: ';
chomp( my $grade = &lt;&gt; );

given ($grade) {
    say 'Well done!'        when 'A';
    say 'Try harder!'       when 'B';
    say 'You need help!!!'  when 'C';
    default { say 'You are just making it up!' }
}

And even more enhancements are coming with perl 5.14 because given now
returns the last evaluated expression:

use 5.013;  # 5.014
use warnings;

print 'Enter your grade: ';
chomp( my $grade = &lt;&gt; );

say do {
    given ($grade) {
        'Well done!'        when 'A';
        'Try harder!'       when 'B';
        'You need help!!!'  when 'C';
        default { 'You are just making it up!' }
    }
};

Which can lead to some very pleasant looking dry code.

But there is more to given/when than just single value conditionals. You
can also check multi-values and ranges:

use 5.012;
use warnings;

print 'Enter your grade: ';
chomp( my $grade = &lt;&gt; );

given ($grade) {
    say 'You pretty smart'  when ['A', 'B'];
    say 'You pretty dumb!!' when ['C', 'D'];
    default { say "You can't even use a computer" }
}

And also pattern match using a regex:

use 5.012;
use warnings;

print 'Enter some text: ';
chomp( my $some_string = &lt;&gt; );

given ($some_string) {
    say 'String has numbers'  when /\d/;
    say 'String has letters'  when /[a-zA-Z]/;
    default { say "String has no numbers or letters" }
}

In fact you can use anything that Smart Matching can resolve.

And because smart matching is used under the hood by given/when then you
can customise it by overloading the ~~ smart match operator:

use 5.012;
use warnings;

{
    package Vehicle;
    use Moose;
    use overload '~~' =&gt; '_same_wheels', fallback =&gt; 1;

    has number_of_wheels =&gt; (is =&gt; 'rw', isa =&gt; 'Int');

    sub _same_wheels {
        my ($self, $another_vehicle) = @_;
        $self-&gt;number_of_wheels == $another_vehicle-&gt;number_of_wheels;
    }
}

my $four_wheeler =  Vehicle-&gt;new( number_of_wheels =&gt;  4 );
my $two_wheeler  =  Vehicle-&gt;new( number_of_wheels =&gt;  2 );
my $robin_reliant = Vehicle-&gt;new( number_of_wheels =&gt;  3 );

print 'Enter number of wheel for vehicles: '; chomp( my $wheels = &lt;&gt; );
my $vehicle = Vehicle-&gt;new( number_of_wheels =&gt; $wheels );

given ($vehicle) {
    say 'Vehicle has the same number of wheels as a two-wheeler!'
        when $two_wheeler;

    say 'Vehicle has the same number of wheels as a four-wheeler!'
        when $four_wheeler;

    say 'Gosh... is that Del Trotter!!'
        when $robin_reliant;

    default {
        say   "Don't know of a vehicle with that wheel arrangement!"
    }
}

Hopefully that was a nice lightweight introduction to given/when. And I
haven’t even touched upon break or continue :)

/I3az/</summary>
    <content type="html">&lt;p&gt;Its been a while since my last post; summer holidays have inflicted upon me some big distractions!   So to ease myself back in gently I&amp;#8217;ll I&amp;#8217;ve pulled out a (nearly finished but unposted) article from last year (in true &lt;a href="http://en.wikipedia.org/wiki/Blue_Peter"&gt;Blue Peter&lt;/a&gt; tradition!)&lt;/p&gt;
&lt;p&gt;This post was inspired by this nice &amp;amp; straightforward blog article: &lt;a href="http://www.skorks.com/2009/08/how-a-ruby-case-statement-works-and-what-you-can-do-with-it/"&gt;How A Ruby Case Statement Works And What You Can Do With It&lt;/a&gt;.  I&amp;#8217;ve simply converted the Ruby code to Perl and added some so called insightful notes &lt;img src="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=":)"&gt; &lt;/p&gt;
&lt;p&gt;Now what Ruby calls &lt;code&gt;case/when&lt;/code&gt; statements is more commonly known in computer parlance has the &lt;a href="http://en.wikipedia.org/wiki/Switch_statement"&gt;switch statement&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Perl itself has had such a &lt;a href="http://perldoc.perl.org/5.8.9/Switch.html"&gt;switch statement&lt;/a&gt; for quite a while now:&lt;/p&gt;
&lt;pre class="brush: perl;"&gt;
use Switch;

switch ($grade) {
    case &amp;quot;A&amp;quot;   { say &amp;quot;Well done!&amp;quot; }
    case &amp;quot;B&amp;quot;   { say &amp;quot;Try harder!&amp;quot; }
    case &amp;quot;C&amp;quot;   { say &amp;quot;You need help!!!&amp;quot; }
    else         { print &amp;quot;You just making it up&amp;quot; }
}
&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;However DON&amp;#8217;T USE IT!!!&lt;/b&gt; Its a source filter and is being deprecated.&lt;/p&gt;
&lt;p&gt;Instead use &lt;a href="http://search.cpan.org/dist/perl-5.10.0/pod/perl5100delta.pod#Switch_and_Smart_Match_operator"&gt;given/when&lt;/a&gt; which is the Perl 6 &lt;em&gt;switch statement&lt;/em&gt; that was introduced at perl 5.10.&lt;/p&gt;
&lt;pre class="brush: perl;"&gt;
use strict;
use warnings;
use feature qw(switch say);

print 'Enter your grade: ';
chomp( my $grade = &amp;lt;&amp;gt; );

given ($grade) {
    when ('A') { say 'Well done!'       }
    when ('B') { say 'Try harder!'      }
    when ('C') { say 'You need help!!!' }
    default { say 'You are just making it up!' }
}
&lt;/pre&gt;
&lt;p&gt;And at perl 5.12 you could also use &lt;code&gt;when&lt;/code&gt; has a &lt;a href="http://search.cpan.org/dist/perl-5.12.0/pod/perl5120delta.pod#when_as_a_statement_modifier"&gt;statement modifiers&lt;/a&gt;:&lt;/p&gt;
&lt;pre class="brush: perl;"&gt;
use 5.012;
use warnings;

print 'Enter your grade: ';
chomp( my $grade = &amp;lt;&amp;gt; );

given ($grade) {
    say 'Well done!'        when 'A';
    say 'Try harder!'       when 'B';
    say 'You need help!!!'  when 'C';
    default { say 'You are just making it up!' }
}
&lt;/pre&gt;
&lt;p&gt;And even more enhancements are coming with perl 5.14 because &lt;code&gt;given&lt;/code&gt; now returns the &lt;a href="http://search.cpan.org/dist/perl-5.13.4/pod/perl5131delta.pod#given_return_values"&gt;last evaluated expression&lt;/a&gt;:&lt;/p&gt;
&lt;pre class="brush: perl;"&gt;
use 5.013;  # 5.014
use warnings;

print 'Enter your grade: ';
chomp( my $grade = &amp;lt;&amp;gt; );

say do {
    given ($grade) {
        'Well done!'        when 'A';
        'Try harder!'       when 'B';
        'You need help!!!'  when 'C';
        default { 'You are just making it up!' }
    }
};
&lt;/pre&gt;
&lt;p&gt;Which can lead to some very pleasant looking dry code.&lt;/p&gt;
&lt;p&gt;But there is more to &lt;code&gt;given/when&lt;/code&gt; than just single value conditionals.  You can also check multi-values and ranges:&lt;/p&gt;
&lt;pre class="brush: perl;"&gt;
use 5.012;
use warnings;

print 'Enter your grade: ';
chomp( my $grade = &amp;lt;&amp;gt; );

given ($grade) {
    say 'You pretty smart'  when ['A', 'B'];
    say 'You pretty dumb!!' when ['C', 'D'];
    default { say &amp;quot;You can't even use a computer&amp;quot; }
}
&lt;/pre&gt;
&lt;p&gt;And also pattern match using a regex:&lt;/p&gt;
&lt;pre class="brush: perl;"&gt;
use 5.012;
use warnings;

print 'Enter some text: ';
chomp( my $some_string = &amp;lt;&amp;gt; );

given ($some_string) {
    say 'String has numbers'  when /\d/;
    say 'String has letters'  when /[a-zA-Z]/;
    default { say &amp;quot;String has no numbers or letters&amp;quot; }
}
&lt;/pre&gt;
&lt;p&gt;In fact you can use anything that &lt;a href="http://search.cpan.org/dist/perl-5.13.4/pod/perlsyn.pod#Smart_matching_in_detail"&gt;Smart Matching&lt;/a&gt; can resolve.&lt;/p&gt;
&lt;p&gt;And because smart matching is used under the hood by &lt;code&gt;given/when&lt;/code&gt; then you can customise it by overloading the &lt;code&gt;~~&lt;/code&gt; smart match operator:&lt;/p&gt;
&lt;pre class="brush: perl;"&gt;
use 5.012;
use warnings;

{
    package Vehicle;
    use Moose;
    use overload '~~' =&amp;gt; '_same_wheels', fallback =&amp;gt; 1;

    has number_of_wheels =&amp;gt; (is =&amp;gt; 'rw', isa =&amp;gt; 'Int');

    sub _same_wheels {
        my ($self, $another_vehicle) = @_;
        $self-&amp;gt;number_of_wheels == $another_vehicle-&amp;gt;number_of_wheels;
    }
}

my $four_wheeler =  Vehicle-&amp;gt;new( number_of_wheels =&amp;gt;  4 );
my $two_wheeler  =  Vehicle-&amp;gt;new( number_of_wheels =&amp;gt;  2 );
my $robin_reliant = Vehicle-&amp;gt;new( number_of_wheels =&amp;gt;  3 );

print 'Enter number of wheel for vehicles: '; chomp( my $wheels = &amp;lt;&amp;gt; );
my $vehicle = Vehicle-&amp;gt;new( number_of_wheels =&amp;gt; $wheels );

given ($vehicle) {
    say 'Vehicle has the same number of wheels as a two-wheeler!'
        when $two_wheeler;

    say 'Vehicle has the same number of wheels as a four-wheeler!'
        when $four_wheeler;

    say 'Gosh... is that Del Trotter!!'
        when $robin_reliant;

    default {
        say   &amp;quot;Don't know of a vehicle with that wheel arrangement!&amp;quot;
    }
}
&lt;/pre&gt;
&lt;p&gt;Hopefully that was a nice lightweight introduction to &lt;code&gt;given/when&lt;/code&gt;.  And I haven&amp;#8217;t even touched upon &lt;a href="http://perldoc.perl.org/functions/break.html"&gt;break&lt;/a&gt; or &lt;a href="http://perldoc.perl.org/functions/continue.html"&gt;continue&lt;/a&gt; &lt;img src="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=":)"&gt; &lt;/p&gt;
&lt;p&gt;/I3az/&lt;/p&gt;
&lt;br /&gt;  &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/draegtun.wordpress.com/1072/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/comments/draegtun.wordpress.com/1072/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/draegtun.wordpress.com/1072/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/delicious/draegtun.wordpress.com/1072/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/draegtun.wordpress.com/1072/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/facebook/draegtun.wordpress.com/1072/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/draegtun.wordpress.com/1072/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/twitter/draegtun.wordpress.com/1072/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/draegtun.wordpress.com/1072/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/stumble/draegtun.wordpress.com/1072/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/draegtun.wordpress.com/1072/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/digg/draegtun.wordpress.com/1072/"&gt;&lt;/a&gt; &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/draegtun.wordpress.com/1072/"&gt;&lt;img alt="" src="http://feeds.wordpress.com/1.0/reddit/draegtun.wordpress.com/1072/"&gt;&lt;/a&gt; &lt;img alt="" src="http://stats.wordpress.com/b.gif?host=transfixedbutnotdead.com&amp;amp;blog=351142&amp;amp;post=1072&amp;amp;subd=draegtun&amp;amp;ref=&amp;amp;feed=1"&gt;</content>
    <category term="Programming perl perl 5.10 perl 5.12 switch"/>
    <published>2010-08-30T20:13:15Z</published>
    <updated>2010-08-30T20:13:15Z</updated>
    <author>
      <name>draegtun</name>
    </author>
    <id>tag:perlsphere.net,2006:http://transfixedbutnotdead.com/?p=1072</id>
    <link xmlns="http://purl.org/atom/ns#" rel="enclosure" type="" href="" length=""/>
  </entry>
  <entry>
    <title>Backporting Features</title>
    <link rel="alternate" href="http://www.modernperlbooks.com/mt/2010/08/backporting-features.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">One current discussion on p5p is the namespace of fixed versions of
reftype(), refaddr(), and blessed(), recently added to bleadperl.

These functions are part of Scalar::Util right now. Unfortunately, they
return undef for non references. This leads to code like:

my $ref_type = reftype( $maybe_ref );
do_something_with_ref( $ref_type ) if defined $ref_type;

(If you don't follow all of the reasons why you have to do that, that's
good; you haven't imagined all of the odd and strange ways people might
name their classes in various parts of the Perl 5 internals and DarkPAN
modules. Safety dictates finding these corner cases.)

Anyhow.

Making these fixed functions available in the core without having to load
Scalar::Util offers some advantages but also some disadvantages. It's the
"You can't add new keywords to Perl 5" problem. What if someone else
defined functions of that name?

Worse, what if someone loads Scalar::Util and imports its functions and
expects those semantics instead of the new semantics?

(Apparently it's impossible to detect the declaration or importation of
symbols with conflicting names so as to produce warnings or exceptions in
this case, though I don't see why. If we were in the habit of declaring
the version of Perl 5 our code uses, we wouldn't have these problems.)

The discussion inevitably circled back to the ineffable question of "If
this new feature is going in the core, how do people use it in previous
releases of Perl 5?" That is, "You've added a new feature to Perl 5 which
will be in Perl 5.14 released next year. Is there any way to backport
that feature to Perl 5.12? How about Perl 5.10? You know, RHEL 3 is still
around. Why do you hate Perl .5.8?"

At some point the weight of ensuring that code written for a future
version of Perl 5 can run correctly (if you cram in enough flying
buttresses of CPAN shims) on code written for obsolete versions of Perl 5
will pull down the entire edifice. Allowing code written for previous
versions of Perl 5 to run on modern versions unmodified (or with a simple
use 5.10; at the top—I know a great combination of find and sed which can
perform this kind of textual manipulation {and if you're on Windows, use
PPT to get portable versions of these tools}) is often good and useful.

Going the other way... well, I don't understand it. If it's possible and
someone wants to do it, fine. Why should it block improving the next
release of Perl 5 though?</div>
    </summary>
    <content type="html">
        &lt;p&gt;One current discussion on p5p is &lt;a href="http://www.nntp.perl.org/group/perl.perl5.porters/2010/08/msg163566.html"&gt;the namespace of fixed versions of &lt;code&gt;reftype()&lt;/code&gt;, &lt;code&gt;refaddr()&lt;/code&gt;, and &lt;code&gt;blessed()&lt;/code&gt;&lt;/a&gt;, recently added to bleadperl.&lt;/p&gt;

&lt;p&gt;These functions are part of &lt;a href="http://search.cpan.org/perldoc?Scalar::Util"&gt;Scalar::Util&lt;/a&gt; right now.  Unfortunately, they return undef for non references.  This leads to code like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $ref_type = reftype( $maybe_ref );
do_something_with_ref( $ref_type ) if defined $ref_type;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(If you don't follow all of the reasons why you have to do that, that's good; you haven't imagined all of the odd and strange ways people might name their classes in various parts of the Perl 5 internals and DarkPAN modules.  Safety dictates finding these corner cases.)&lt;/p&gt;

&lt;p&gt;Anyhow.&lt;/p&gt;

&lt;p&gt;Making these fixed functions available in the core without having to load &lt;code&gt;Scalar::Util&lt;/code&gt; offers some advantages but also some disadvantages.  It's the "&lt;a href="http://www.modernperlbooks.com/mt/2009/06/yagni-badvocacy-and-the-perlian-knot.html"&gt;You can't add new keywords to Perl 5&lt;/a&gt;" problem.  What if someone else defined functions of that name?&lt;/p&gt;

&lt;p&gt;Worse, what if someone loads &lt;code&gt;Scalar::Util&lt;/code&gt; and imports its functions and expects those semantics instead of the new semantics?&lt;/p&gt;

&lt;p&gt;(Apparently it's impossible to detect the declaration or importation of symbols with conflicting names so as to produce warnings or exceptions in this case, though I don't see why.  If we were in the habit of &lt;a href="http://www.modernperlbooks.com/mt/2009/12/the-guess-the-version-game.html"&gt;declaring the version of Perl 5 our code uses&lt;/a&gt;, we wouldn't have these problems.)&lt;/p&gt;

&lt;p&gt;The discussion inevitably circled back to the ineffable question of "If this
new feature is going in the core, how do people use it in previous releases of
Perl 5?"  That is, "You've added a new feature to Perl 5 which will be in Perl
5.14 released next year.  Is there any way to backport that feature to Perl
5.12?  How about Perl 5.10?  You know, RHEL 3 is still around.  Why do you hate
Perl .5.8?"&lt;/p&gt;

&lt;p&gt;At some point the weight of ensuring that code written for a future version of Perl 5 can run correctly (if you cram in enough flying buttresses of CPAN shims) on code written for obsolete versions of Perl 5 will pull down the entire edifice.  Allowing code written for previous versions of Perl 5 to run on modern versions unmodified (or with a simple &lt;code&gt;use 5.10;&lt;/code&gt; at the top&amp;mdash;I know a great combination of &lt;code&gt;find&lt;/code&gt; and &lt;code&gt;sed&lt;/code&gt; which can perform this kind of textual manipulation {and if you're on Windows, use &lt;a href="http://search.cpan.org/perldoc?PPT::Util"&gt;PPT&lt;/a&gt; to get portable versions of these tools}) is often good and useful.&lt;/p&gt;

&lt;p&gt;Going the other way... well, I don't understand it.  If it's &lt;em&gt;possible&lt;/em&gt; and someone wants to do it, fine.  Why should it block improving the next release of Perl 5 though?&lt;/p&gt;
        
    </content>
    <category term="language design modern perl perl 5"/>
    <published>2010-08-30T18:49:28Z</published>
    <updated>2010-08-30T18:49:28Z</updated>
    <author>
      <name>chromatic</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:www.modernperlbooks.com,2010:/mt//1.222</id>
  </entry>
  <entry>
    <title>Prime Factors in Perl 6</title>
    <link rel="alternate" href="http://blogs.perl.org/users/ovid/2010/08/prime-factors-in-perl-6.html" type="text/html"/>
    <summary type="text">There's really nothing extraordinary about this and certainly nothing
specific to Perl 6, but I really liked how it felt writing code to find
prime factors. I do note, however, that the habit of using a dash instead
of an underscore in identifiers does slow down the Perl 6 to Perl 5
translation (since I'm doing that manually). Hopefully we won't need to
keep doing that translation in the future.

sub prime-factors(Int $number is copy) {
    # don't try to factor prime numbers
    return { $number =&gt; 1 } if is-prime($number);

    my %factors;
    for @PRIMES -&gt; $prime-number {
        last if $prime-number ** 2 &gt; $number;
        while $number % $prime-number == 0 {
            %factors{$prime-number} //= 0;
            %factors{$prime-number}++;
            $number /= $prime-number;
        }
    }
    %factors{$number}++ if $number != 1;  # we have a prime left over
    return %factors;
}

for 17, 53, 90, 94, 200, 289, 62710561 -&gt; $number {
    say "Prime factors of $number are: ", prime-factors($number).perl;
}

The is-prime sub merely relies on a list of the first 1000 prime numbers
(kept in the @PRIMES array). It was much faster that way. If you
desperately must see it, it's in the extended part of the blog entry.

It takes almost 7 seconds to run on my MacBook Pro, but .007 under Perl
5. I think I'll keep this one around for a while to see Rakudo benchmark
improvements. As usual, code improvements welcome.

And the boring bit:

my @PRIMES = &lt;2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53
59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163
167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269
271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383
389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499
503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619
631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751
757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881
883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 1009 1013 1019
1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109
1117 1123 1129 1151 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229
1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321
1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453
1459 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559
1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663
1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783
1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 1901
1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017
2027 2029 2039 2053 2063 2069 2081 2083 2087 2089 2099 2111 2113 2129 2131
2137 2141 2143 2153 2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267
2269 2273 2281 2287 2293 2297 2309 2311 2333 2339 2341 2347 2351 2357 2371
2377 2381 2383 2389 2393 2399 2411 2417 2423 2437 2441 2447 2459 2467 2473
2477 2503 2521 2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617 2621
2633 2647 2657 2659 2663 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713
2719 2729 2731 2741 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833
2837 2843 2851 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957
2963 2969 2971 2999 3001 3011 3019 3023 3037 3041 3049 3061 3067 3079 3083
3089 3109 3119 3121 3137 3163 3167 3169 3181 3187 3191 3203 3209 3217 3221
3229 3251 3253 3257 3259 3271 3299 3301 3307 3313 3319 3323 3329 3331 3343
3347 3359 3361 3371 3373 3389 3391 3407 3413 3433 3449 3457 3461 3463 3467
3469 3491 3499 3511 3517 3527 3529 3533 3539 3541 3547 3557 3559 3571 3581
3583 3593 3607 3613 3617 3623 3631 3637 3643 3659 3671 3673 3677 3691 3697
3701 3709 3719 3727 3733 3739 3761 3767 3769 3779 3793 3797 3803 3821 3823
3833 3847 3851 3853 3863 3877 3881 3889 3907 3911 3917 3919 3923 3929 3931
3943 3947 3967 3989 4001 4003 4007 4013 4019 4021 4027 4049 4051 4057 4073
4079 4091 4093 4099 4111 4127 4129 4133 4139 4153 4157 4159 4177 4201 4211
4217 4219 4229 4231 4241 4243 4253 4259 4261 4271 4273 4283 4289 4297 4327
4337 4339 4349 4357 4363 4373 4391 4397 4409 4421 4423 4441 4447 4451 4457
4463 4481 4483 4493 4507 4513 4517 4519 4523 4547 4549 4561 4567 4583 4591
4597 4603 4621 4637 4639 4643 4649 4651 4657 4663 4673 4679 4691 4703 4721
4723 4729 4733 4751 4759 4783 4787 4789 4793 4799 4801 4813 4817 4831 4861
4871 4877 4889 4903 4909 4919 4931 4933 4937 4943 4951 4957 4967 4969 4973
4987 4993 4999 5003 5009 5011 5021 5023 5039 5051 5059 5077 5081 5087 5099
5101 5107 5113 5119 5147 5153 5167 5171 5179 5189 5197 5209 5227 5231 5233
5237 5261 5273 5279 5281 5297 5303 5309 5323 5333 5347 5351 5381 5387 5393
5399 5407 5413 5417 5419 5431 5437 5441 5443 5449 5471 5477 5479 5483 5501
5503 5507 5519 5521 5527 5531 5557 5563 5569 5573 5581 5591 5623 5639 5641
5647 5651 5653 5657 5659 5669 5683 5689 5693 5701 5711 5717 5737 5741 5743
5749 5779 5783 5791 5801 5807 5813 5821 5827 5839 5843 5849 5851 5857 5861
5867 5869 5879 5881 5897 5903 5923 5927 5939 5953 5981 5987 6007 6011 6029
6037 6043 6047 6053 6067 6073 6079 6089 6091 6101 6113 6121 6131 6133 6143
6151 6163 6173 6197 6199 6203 6211 6217 6221 6229 6247 6257 6263 6269 6271
6277 6287 6299 6301 6311 6317 6323 6329 6337 6343 6353 6359 6361 6367 6373
6379 6389 6397 6421 6427 6449 6451 6469 6473 6481 6491 6521 6529 6547 6551
6553 6563 6569 6571 6577 6581 6599 6607 6619 6637 6653 6659 6661 6673 6679
6689 6691 6701 6703 6709 6719 6733 6737 6761 6763 6779 6781 6791 6793 6803
6823 6827 6829 6833 6841 6857 6863 6869 6871 6883 6899 6907 6911 6917 6947
6949 6959 6961 6967 6971 6977 6983 6991 6997 7001 7013 7019 7027 7039 7043
7057 7069 7079 7103 7109 7121 7127 7129 7151 7159 7177 7187 7193 7207 7211
7213 7219 7229 7237 7243 7247 7253 7283 7297 7307 7309 7321 7331 7333 7349
7351 7369 7393 7411 7417 7433 7451 7457 7459 7477 7481 7487 7489 7499 7507
7517 7523 7529 7537 7541 7547 7549 7559 7561 7573 7577 7583 7589 7591 7603
7607 7621 7639 7643 7649 7669 7673 7681 7687 7691 7699 7703 7717 7723 7727
7741 7753 7757 7759 7789 7793 7817 7823 7829 7841 7853 7867 7873 7877 7879
7883 7901 7907 7919&gt;;
my %IS-PRIME = map {; $_ =&gt; 1 }, @PRIMES;

sub is-prime(Int $number) {
    return False  if $number &lt; 2; # special case
    die "$number is too large" if $number &gt; @PRIMES[*-1]**2;
    return %IS-PRIME{$number};
}

See, I told you that bit was boring :)</summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>There's really nothing extraordinary about this and certainly nothing specific to Perl 6, but I really liked how it felt writing code to find prime factors.  I do note, however, that the habit of using a dash instead of an underscore in identifiers does slow down the Perl 6 to Perl 5 translation (since I'm doing that manually).  Hopefully we won't need to keep doing that translation in the future.</p>

<pre><code>sub prime-factors(Int $number is copy) {
    # don't try to factor prime numbers
    return { $number =&gt; 1 } if is-prime($number);

    my %factors;
    for @PRIMES -&gt; $prime-number {
        last if $prime-number ** 2 &gt; $number;
        while $number % $prime-number == 0 {
            %factors{$prime-number} //= 0;
            %factors{$prime-number}++;
            $number /= $prime-number;
        }
    }
    %factors{$number}++ if $number != 1;  # we have a prime left over
    return %factors;
}

for 17, 53, 90, 94, 200, 289, 62710561 -&gt; $number {
    say "Prime factors of $number are: ", prime-factors($number).perl;
}
</code></pre>

<p>The <tt>is-prime</tt> sub merely relies on a list of the first 1000 prime numbers (kept in the <tt>@PRIMES</tt> array).  It was much faster that way.  If you desperately <em>must</em> see it, it's in the extended part of the blog entry.</p>

<p>It takes almost 7 seconds to run on my MacBook Pro, but .007 under Perl 5.  I think I'll keep this one around for a while to see Rakudo benchmark improvements.  As usual, code improvements welcome.</p>

        <p>And the boring bit:</p>

<pre><code>my @PRIMES = &lt;2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53
59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163
167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269
271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383
389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499
503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619
631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751
757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881
883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 1009 1013 1019
1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109
1117 1123 1129 1151 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229
1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321
1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453
1459 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559
1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663
1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783
1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 1901
1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017
2027 2029 2039 2053 2063 2069 2081 2083 2087 2089 2099 2111 2113 2129 2131
2137 2141 2143 2153 2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267
2269 2273 2281 2287 2293 2297 2309 2311 2333 2339 2341 2347 2351 2357 2371
2377 2381 2383 2389 2393 2399 2411 2417 2423 2437 2441 2447 2459 2467 2473
2477 2503 2521 2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617 2621
2633 2647 2657 2659 2663 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713
2719 2729 2731 2741 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833
2837 2843 2851 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957
2963 2969 2971 2999 3001 3011 3019 3023 3037 3041 3049 3061 3067 3079 3083
3089 3109 3119 3121 3137 3163 3167 3169 3181 3187 3191 3203 3209 3217 3221
3229 3251 3253 3257 3259 3271 3299 3301 3307 3313 3319 3323 3329 3331 3343
3347 3359 3361 3371 3373 3389 3391 3407 3413 3433 3449 3457 3461 3463 3467
3469 3491 3499 3511 3517 3527 3529 3533 3539 3541 3547 3557 3559 3571 3581
3583 3593 3607 3613 3617 3623 3631 3637 3643 3659 3671 3673 3677 3691 3697
3701 3709 3719 3727 3733 3739 3761 3767 3769 3779 3793 3797 3803 3821 3823
3833 3847 3851 3853 3863 3877 3881 3889 3907 3911 3917 3919 3923 3929 3931
3943 3947 3967 3989 4001 4003 4007 4013 4019 4021 4027 4049 4051 4057 4073
4079 4091 4093 4099 4111 4127 4129 4133 4139 4153 4157 4159 4177 4201 4211
4217 4219 4229 4231 4241 4243 4253 4259 4261 4271 4273 4283 4289 4297 4327
4337 4339 4349 4357 4363 4373 4391 4397 4409 4421 4423 4441 4447 4451 4457
4463 4481 4483 4493 4507 4513 4517 4519 4523 4547 4549 4561 4567 4583 4591
4597 4603 4621 4637 4639 4643 4649 4651 4657 4663 4673 4679 4691 4703 4721
4723 4729 4733 4751 4759 4783 4787 4789 4793 4799 4801 4813 4817 4831 4861
4871 4877 4889 4903 4909 4919 4931 4933 4937 4943 4951 4957 4967 4969 4973
4987 4993 4999 5003 5009 5011 5021 5023 5039 5051 5059 5077 5081 5087 5099
5101 5107 5113 5119 5147 5153 5167 5171 5179 5189 5197 5209 5227 5231 5233
5237 5261 5273 5279 5281 5297 5303 5309 5323 5333 5347 5351 5381 5387 5393
5399 5407 5413 5417 5419 5431 5437 5441 5443 5449 5471 5477 5479 5483 5501
5503 5507 5519 5521 5527 5531 5557 5563 5569 5573 5581 5591 5623 5639 5641
5647 5651 5653 5657 5659 5669 5683 5689 5693 5701 5711 5717 5737 5741 5743
5749 5779 5783 5791 5801 5807 5813 5821 5827 5839 5843 5849 5851 5857 5861
5867 5869 5879 5881 5897 5903 5923 5927 5939 5953 5981 5987 6007 6011 6029
6037 6043 6047 6053 6067 6073 6079 6089 6091 6101 6113 6121 6131 6133 6143
6151 6163 6173 6197 6199 6203 6211 6217 6221 6229 6247 6257 6263 6269 6271
6277 6287 6299 6301 6311 6317 6323 6329 6337 6343 6353 6359 6361 6367 6373
6379 6389 6397 6421 6427 6449 6451 6469 6473 6481 6491 6521 6529 6547 6551
6553 6563 6569 6571 6577 6581 6599 6607 6619 6637 6653 6659 6661 6673 6679
6689 6691 6701 6703 6709 6719 6733 6737 6761 6763 6779 6781 6791 6793 6803
6823 6827 6829 6833 6841 6857 6863 6869 6871 6883 6899 6907 6911 6917 6947
6949 6959 6961 6967 6971 6977 6983 6991 6997 7001 7013 7019 7027 7039 7043
7057 7069 7079 7103 7109 7121 7127 7129 7151 7159 7177 7187 7193 7207 7211
7213 7219 7229 7237 7243 7247 7253 7283 7297 7307 7309 7321 7331 7333 7349
7351 7369 7393 7411 7417 7433 7451 7457 7459 7477 7481 7487 7489 7499 7507
7517 7523 7529 7537 7541 7547 7549 7559 7561 7573 7577 7583 7589 7591 7603
7607 7621 7639 7643 7649 7669 7673 7681 7687 7691 7699 7703 7717 7723 7727
7741 7753 7757 7759 7789 7793 7817 7823 7829 7841 7853 7867 7873 7877 7879
7883 7901 7907 7919&gt;;
my %IS-PRIME = map {; $_ =&gt; 1 }, @PRIMES;

sub is-prime(Int $number) {
    return False  if $number &lt; 2; # special case
    die "$number is too large" if $number &gt; @PRIMES[*-1]**2;
    return %IS-PRIME{$number};
}
</code></pre>

<p>See, I told you that bit was boring :)</p>

    </div>
    </content>
    <category term="benchmark perl 6 rakudo"/>
    <published>2010-08-30T12:13:10Z</published>
    <updated>2010-08-30T12:13:10Z</updated>
    <author>
      <name>Ovid</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:blogs.perl.org,2010:/users/ovid//11.959</id>
  </entry>
  <entry>
    <title>Use when() as a statement modifier</title>
    <link rel="alternate" href="http://www.effectiveperlprogramming.com/blog/543" type="text/html"/>
    <summary type="text">Perl 5.10 introduced the given-when statement, and Perl 5.12 refines it
slightly by letting you use the when as a statement modifier.

A statement modifier puts the conditional expression at the end of the
statement (see perlsyn). You’ve probably already used many of these:

print "It's too darned hot!\n" if $city eq 'Baltimore';
print "I'm this far!\n" unless $Quiet;
print "An element is $_.\n" foreach @array;
print "Found cat at @{[pos]}\n" while /cat/g;
do { $count++; $i_am_bored = int rand 2 } until $i_am_bored;

In Perl 5.10, you have to put the when first, put parentheses around the
conditional expression, and follow it with a block:

use 5.012;

my %microchips = (
          'Mimi'   =&gt; 123,
          'Buster' =&gt; undef,
          'Roscoe' =&gt; 345,
        );
my @array = ( 5 .. 7 );

foreach ( 1 .. 10, qw(Mimi Buster) ) {
        when( @array )      { say "$_: in array" }
        when( %microchips ) { say "$_: in hash"  }
        }

Perl 5.12 allows you to use the when as a statement modifier instead,
which means that you can put the when after the expression that you want
to run:

use 5.012;

...;

foreach ( 1 .. 10, qw(Mimi Buster) ) {
        say "$_: in array" when( @array );
        say "$_: in hash"  when( %microchips );
        }

Just like you can with the other statement modifiers, you can omit the
parentheses around the condition:

use 5.012;

...;

foreach ( 1 .. 10, qw(Mimi Buster) ) {
        say "$_: in array" when @array;
        say "$_: in hash"  when %microchips;
        }

As a statement modifier, the expression before the when has an implicit
break when you use it with given or an implicit next when you use it with
foreach. That is, once a when condition evaluates to true, Perl doesn’t
continue with the rest of the block.

The foreach case actually looks like this:

use 5.012;

...;

foreach ( 1 .. 10, qw(Mimi Buster) ) {
        do { say "$_: in array"; next } when @array;
        do { say "$_: in hash";  next } when %microchips;
        }

And the given case actually looks like:

use 5.012;

...;

given ( $cat ) {
        do { say "$_: in array"; break } when @array;
        do { say "$_: in hash";  break } when %microchips;
        }

You’re still supposed to use when inside a topicalizer (e.g. foreach or
given). You might be tempted to use it more liberally so you can take
advantage of its implicit smart matching anywhere that you like. A
curious and perhaps unintended parsing makes it a runtime error instead
of a compilation error:

use 5.012;

my %microchips = (
          'Mimi'   =&gt; 123,
          'Buster' =&gt; undef,
          'Roscoe' =&gt; 345,
        );

while( &lt;STDIN&gt; ) {
        chomp;
        # this works (without a warning) as long as the value in $_
        # is not a hash key
        say "Found cat with id [$microchips{$_}]" when %microchips;
        }

The while isn’t a topicalizer, even though in this particular idiom it
sets $_ for you. You get the output along with a warning:

$ perl5.12.1 no-topicalizer.pl
Buster
Found cat with id []
Can't use when() outside a topicalizer at test line 11, &lt;STDIN&gt; line 1.

However, you don’t get a fatal error when the condition is false, which
is probably another bug (filed as RT #77510). There’s no fatal error, no
warning message, and the output shows that Perl kept going:

Ella
Mimi
Found cat with id 123
Can't use when() outside a topicalizer at test line 11, &lt;STDIN&gt; line 2.

Just because it it does just what you think it should do then dies
telling you it doesn’t do that, don’t think you should do it. You could
use eval to catch the fatal error, but that’s a kludge that will only
work until the Perl developers fix the problem. Besides, if you are going
to go that far, it’s just as easy to make the smart match explicit with
an if statement modifier (and that is even backward compatible with
5.10):

use 5.010;

my %microchips = (
          'Mimi'   =&gt; 123,
          'Buster' =&gt; undef,
          'Roscoe' =&gt; 345,
        );

while( &lt;STDIN&gt; ) {
        chomp;
        say "Found cat with id $microchips{$_}" if $_ ~~ %microchips;
        }

The only question now is how long you will be able to use this before
your Perl::Critic policies update to forbid it, whether inside or outside
of a topicalizer. Use it while you can: time is running out.

Post to Twitter Post to Delicious Post to Digg Post to Facebook
Post to Reddit</summary>
    <content type="html">&lt;p&gt;Perl 5.10 introduced the &lt;code&gt;given-when&lt;/code&gt; statement, and Perl 5.12 refines it slightly by letting you use the &lt;code&gt;when&lt;/code&gt; as a statement modifier.&lt;/p&gt;
&lt;p&gt;A statement modifier puts the conditional expression at the end of the statement (see &lt;a href="http://perldoc.perl.org/perlsyn.html"&gt;perlsyn&lt;/a&gt;). You&amp;#8217;ve probably already used many of these:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
print "It's too darned hot!\n" if $city eq 'Baltimore';
print "I'm this far!\n" unless $Quiet;
print "An element is $_.\n" foreach @array;
print "Found cat at @{[pos]}\n" while /cat/g;
do { $count++; $i_am_bored = int rand 2 } until $i_am_bored;
&lt;/pre&gt;
&lt;p&gt;In Perl 5.10, you have to put the &lt;code&gt;when&lt;/code&gt; first, put parentheses around the conditional expression, and follow it with a block:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
use 5.012;

my %microchips = (
	  'Mimi'   =&amp;gt; 123,
	  'Buster' =&amp;gt; undef,
	  'Roscoe' =&amp;gt; 345,
	);
my @array = ( 5 .. 7 );

foreach ( 1 .. 10, qw(Mimi Buster) ) {
	when( @array )      { say "$_: in array" }
	when( %microchips ) { say "$_: in hash"  }
	}
&lt;/pre&gt;
&lt;p&gt;Perl 5.12 allows you to use the &lt;code&gt;when&lt;/code&gt; as a statement modifier instead, which means that you can put the &lt;code&gt;when&lt;/code&gt; after the expression that you want to run:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
use 5.012;

...;

foreach ( 1 .. 10, qw(Mimi Buster) ) {
	say "$_: in array" when( @array );
	say "$_: in hash"  when( %microchips );
	}
&lt;/pre&gt;
&lt;p&gt;Just like you can with the other statement modifiers, you can omit the parentheses around the condition:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
use 5.012;

...;

foreach ( 1 .. 10, qw(Mimi Buster) ) {
	say "$_: in array" when @array;
	say "$_: in hash"  when %microchips;
	}
&lt;/pre&gt;
&lt;p&gt;As a statement modifier, the expression before the &lt;code&gt;when&lt;/code&gt; has an implicit &lt;code&gt;break&lt;/code&gt; when you use it with &lt;code&gt;given&lt;/code&gt; or an implicit &lt;code&gt;next&lt;/code&gt; when you use it with &lt;code&gt;foreach&lt;/code&gt;. That is, once a &lt;code&gt;when&lt;/code&gt; condition evaluates to true, Perl doesn&amp;#8217;t continue with the rest of the block. &lt;/p&gt;
&lt;p&gt;The &lt;code&gt;foreach&lt;/code&gt; case actually looks like this:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
use 5.012;

...;

foreach ( 1 .. 10, qw(Mimi Buster) ) {
	do { say "$_: in array"; next } when @array;
	do { say "$_: in hash";  next } when %microchips;
	}
&lt;/pre&gt;
&lt;p&gt;And the &lt;code&gt;given&lt;/code&gt; case actually looks like:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
use 5.012;

...;

given ( $cat ) {
	do { say "$_: in array"; break } when @array;
	do { say "$_: in hash";  break } when %microchips;
	}
&lt;/pre&gt;
&lt;p&gt;You&amp;#8217;re still supposed to use &lt;code&gt;when&lt;/code&gt; inside a topicalizer (e.g. &lt;code&gt;foreach&lt;/code&gt; or &lt;code&gt;given&lt;/code&gt;). You might be tempted to use it more liberally so you can take advantage of its implicit smart matching anywhere that you like. A curious and perhaps unintended parsing makes it a runtime error instead of a compilation error:&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
use 5.012;

my %microchips = (
	  'Mimi'   =&amp;gt; 123,
	  'Buster' =&amp;gt; undef,
	  'Roscoe' =&amp;gt; 345,
	);

while( &amp;lt;STDIN&amp;gt; ) {
	chomp;
	# this works (without a warning) as long as the value in $_
	# is not a hash key
	say "Found cat with id [$microchips{$_}]" when %microchips;
	}
&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;while&lt;/code&gt; isn&amp;#8217;t a topicalizer, even though in this particular idiom it sets &lt;code&gt;$_&lt;/code&gt; for you. You get the output along with a warning:&lt;/p&gt;
&lt;pre class="brush:plain"&gt;
$ perl5.12.1 no-topicalizer.pl
Buster
Found cat with id []
Can't use when() outside a topicalizer at test line 11, &amp;lt;STDIN&amp;gt; line 1.
&lt;/pre&gt;
&lt;p&gt;However, you don&amp;#8217;t get a fatal error when the condition is false, which is probably another bug (filed as &lt;a href="http://rt.perl.org/rt3/Ticket/Display.html?id=77510"&gt;RT #77510&lt;/a&gt;). There&amp;#8217;s no fatal error, no warning message, and the output shows that Perl kept going:&lt;/p&gt;
&lt;pre class="brush:plain"&gt;
Ella
Mimi
Found cat with id 123
Can't use when() outside a topicalizer at test line 11, &amp;lt;STDIN&amp;gt; line 2.
&lt;/pre&gt;
&lt;p&gt;Just because it it does just what you think it should do then dies telling you it doesn&amp;#8217;t do that, don&amp;#8217;t think you should do it. You could use &lt;code&gt;eval&lt;/code&gt; to catch the fatal error, but that&amp;#8217;s a kludge that will only work until the Perl developers fix the problem. Besides, if you are going to go that far, it&amp;#8217;s just as easy to make the smart match explicit with an &lt;code&gt;if&lt;/code&gt; statement modifier (and that is even backward compatible with 5.10):&lt;/p&gt;
&lt;pre class="brush:perl"&gt;
use 5.010;

my %microchips = (
	  'Mimi'   =&amp;gt; 123,
	  'Buster' =&amp;gt; undef,
	  'Roscoe' =&amp;gt; 345,
	);

while( &amp;lt;STDIN&amp;gt; ) {
	chomp;
	say "Found cat with id $microchips{$_}" if $_ ~~ %microchips;
	}
&lt;/pre&gt;
&lt;p&gt;The only question now is how long you will be able to use this before your &lt;a href="http://search.cpan.org/dist/Perl-Critic"&gt;Perl::Critic&lt;/a&gt; policies update to forbid it, whether inside or outside of a topicalizer. Use it while you can: time is running out.&lt;/p&gt;
&lt;p align="left"&gt;&lt;a class="tt" href="http://twitter.com/home/?status=Use+when%28%29+as+a+statement+modifier+http://p64x5.th8.us" title="Post to Twitter"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-twitter2.png" alt="Post to Twitter"&gt;&lt;/a&gt; &lt;a class="tt" href="http://twitter.com/home/?status=Use+when%28%29+as+a+statement+modifier+http://p64x5.th8.us" title="Post to Twitter"&gt; &lt;/a&gt; &lt;a class="tt" href="http://delicious.com/post?url=http://www.effectiveperlprogramming.com/blog/543&amp;amp;title=Use+when%28%29+as+a+statement+modifier" title="Post to Delicious"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious"&gt;&lt;/a&gt; &lt;a class="tt" href="http://delicious.com/post?url=http://www.effectiveperlprogramming.com/blog/543&amp;amp;title=Use+when%28%29+as+a+statement+modifier" title="Post to Delicious"&gt; &lt;/a&gt; &lt;a class="tt" href="http://digg.com/submit?url=http://www.effectiveperlprogramming.com/blog/543&amp;amp;title=Use+when%28%29+as+a+statement+modifier" title="Post to Digg"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg"&gt;&lt;/a&gt; &lt;a class="tt" href="http://digg.com/submit?url=http://www.effectiveperlprogramming.com/blog/543&amp;amp;title=Use+when%28%29+as+a+statement+modifier" title="Post to Digg"&gt; &lt;/a&gt; &lt;a class="tt" href="http://www.facebook.com/share.php?u=http://www.effectiveperlprogramming.com/blog/543&amp;amp;t=Use+when%28%29+as+a+statement+modifier" title="Post to Facebook"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-facebook.png" alt="Post to Facebook"&gt;&lt;/a&gt; &lt;a class="tt" href="http://www.facebook.com/share.php?u=http://www.effectiveperlprogramming.com/blog/543&amp;amp;t=Use+when%28%29+as+a+statement+modifier" title="Post to Facebook"&gt; &lt;/a&gt; &lt;a class="tt" href="http://reddit.com/submit?url=http://www.effectiveperlprogramming.com/blog/543&amp;amp;title=Use+when%28%29+as+a+statement+modifier" title="Post to Reddit"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit"&gt;&lt;/a&gt; &lt;a class="tt" href="http://reddit.com/submit?url=http://www.effectiveperlprogramming.com/blog/543&amp;amp;title=Use+when%28%29+as+a+statement+modifier" title="Post to Reddit"&gt; &lt;/a&gt;&lt;/p&gt;</content>
    <category term="5.12"/>
    <published>2010-08-30T05:40:26Z</published>
    <updated>2010-08-30T05:40:26Z</updated>
    <author>
      <name>brian d foy</name>
    </author>
    <id>tag:perlsphere.net,2006:http://www.effectiveperlprogramming.com/?p=543</id>
  </entry>
  <entry>
    <title>Perl Module Release: Image-Size 3.230</title>
    <link rel="alternate" href="http://www.dereferenced.com/2010/08/29/perl-module-release-image-size-3-230/" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Version: 3.230

Released: Sunday August 29, 2010, 04:00:00 PM -0700

Changes:

  * imgsize

  * lib/Image/Size.pm

perlcritic clean-ups from new rules.

  * lib/Image/Size.pm

  * t/Test_emf_small.emf (added)

  * t/all.t

RT #59995: Added support for Windows Enhanced Metafile Format (EMF).

  * t/00_load.t (deleted)

  * t/01_pod.t (deleted)

  * t/02_pod_coverage.t (deleted)

  * t/03_meta.t (deleted)

  * t/04_minimumversion.t (deleted)

  * t/05_critic.t (deleted)

  * xt/00_load.t (added)

  * xt/01_pod.t (added)

  * xt/02_pod_coverage.t (added)

  * xt/03_meta.t (added)

  * xt/04_minimumversion.t (added)

  * xt/05_critic.t (added)

Move the author/distro-sanity tests to an “xt” directory.</div>
    </summary>
    <content type="html">&lt;div xmlns="http://www.w3.org/1999/xhtml" xmlns:cl="http://www.blackperl.com/2009/01/ChangeLogML" xmlns:xhtml="http://www.w3.org/1999/xhtml" id="changelog-container" class="changelog-container-div"&gt;
&lt;div class="changelog-release-div" name="release_3_230" id="release_3_230_div"&gt;
&lt;span class="changelog-release-heading"&gt;Version: 3.230&lt;/span&gt;&lt;br/&gt;&lt;br /&gt;
&lt;span class="changelog-release-date"&gt;Released: &lt;span class="changelog-date"&gt;Sunday August 29, 2010, 04:00:00 PM -0700&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="changelog-release-para"&gt;Changes:&lt;/p&gt;
&lt;div class="changelog-release-changes-container"&gt;
&lt;div class="changelog-release-change"&gt;
&lt;ul class="changelog-release-change-ul"&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;imgsize&lt;/tt&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;lib/Image/Size.pm&lt;/tt&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="changelog-release-change-para"&gt;
perlcritic clean-ups from new rules.
&lt;/p&gt;
&lt;/div&gt;
&lt;div class="changelog-release-change"&gt;
&lt;ul class="changelog-release-change-ul"&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;lib/Image/Size.pm&lt;/tt&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;t/Test_emf_small.emf&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(added)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;t/all.t&lt;/tt&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="changelog-release-change-para"&gt;
&lt;a href="http://rt.cpan.org/Ticket/Display.html?id=59995" class="changelog-html-a"&gt;RT #59995&lt;/a&gt;: Added support for Windows Enhanced Metafile Format (EMF).
&lt;/p&gt;
&lt;/div&gt;
&lt;div class="changelog-release-change"&gt;
&lt;ul class="changelog-release-change-ul"&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;t/00_load.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(deleted)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;t/01_pod.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(deleted)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;t/02_pod_coverage.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(deleted)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;t/03_meta.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(deleted)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;t/04_minimumversion.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(deleted)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;t/05_critic.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(deleted)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;xt/00_load.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(added)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;xt/01_pod.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(added)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;xt/02_pod_coverage.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(added)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;xt/03_meta.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(added)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;xt/04_minimumversion.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(added)&lt;/span&gt;
&lt;/li&gt;
&lt;li class="changelog-release-change-li"&gt;
&lt;tt class="changelog-filename"&gt;xt/05_critic.t&lt;/tt&gt; &lt;span class="changelog-release-file-action"&gt;(added)&lt;/span&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="changelog-release-change-para"&gt;
Move the author/distro-sanity tests to an &amp;#8220;xt&amp;#8221; directory.
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content>
    <category term="CPAN Perl Software Image-Size"/>
    <published>2010-08-29T23:16:38Z</published>
    <updated>2010-08-29T23:16:38Z</updated>
    <author>
      <name>rjray</name>
    </author>
    <id>tag:perlsphere.net,2006:http://www.dereferenced.com/?p=129</id>
  </entry>
  <entry>
    <title>New Android blog!</title>
    <link rel="alternate" href="http://feedproxy.google.com/~r/DamienLearnsPerl/~3/BTBP4__bmu8/new-android-blog.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Hi all!
Just a quick word to tell you about my new blog venture on Android
Application programming. DamienLearnsPerl is not dead, just transfixed ;)
Please check out "Do Androids Dream of Google Apps" for the fun!


[IMAGE]
[IMAGE]

[IMAGE] [IMAGE] [IMAGE] [IMAGE][IMAGE]</div>
    </summary>
    <content type="text">Hi all!&lt;br /&gt;Just a quick word to tell you about my new blog venture on Android Application programming. DamienLearnsPerl is not dead, &lt;a href="http://transfixedbutnotdead.com/"&gt;just transfixed&lt;/a&gt; ;)&lt;br /&gt;Please check out &lt;a href="http://dreamingandroids.com/"&gt;"Do Androids Dream of Google Apps"&lt;/a&gt; for the fun!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img alt=""&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/dzmyY5Nuw9G2AHlEj4KHkz8ORmk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dzmyY5Nuw9G2AHlEj4KHkz8ORmk/0/di"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/dzmyY5Nuw9G2AHlEj4KHkz8ORmk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dzmyY5Nuw9G2AHlEj4KHkz8ORmk/1/di"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DamienLearnsPerl?a=BTBP4__bmu8:IVJtqiOd24Q:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DamienLearnsPerl?i=BTBP4__bmu8:IVJtqiOd24Q:gIN9vFwOqvQ"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DamienLearnsPerl?a=BTBP4__bmu8:IVJtqiOd24Q:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DamienLearnsPerl?i=BTBP4__bmu8:IVJtqiOd24Q:V_sGLiPBpWU"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DamienLearnsPerl?a=BTBP4__bmu8:IVJtqiOd24Q:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DamienLearnsPerl?d=7Q72WNTAKBA"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DamienLearnsPerl?a=BTBP4__bmu8:IVJtqiOd24Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DamienLearnsPerl?d=yIl2AUoC8zA"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DamienLearnsPerl/~4/BTBP4__bmu8"&gt;</content>
    <category term="Android general"/>
    <published>2010-08-28T21:58:00Z</published>
    <updated>2010-08-28T21:58:00Z</updated>
    <author>
      <name>Damien</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:blogger.com,1999:blog-5699142825044889235.post-5040691890829660604</id>
  </entry>
  <entry>
    <title>New mailing address for TPF.</title>
    <link rel="alternate" href="http://news.perlfoundation.org/2010/08/new-mailing-address-for-tpf.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">The Perl Foundation has a new mailing address! We are working to get
contact information on all of our sites updated. Please update your
records:

Yet Another Society d/b/a The Perl Foundation
340 S LEMON AVE #6055
WALNUT, CA 91789
UNITED STATES</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>The Perl Foundation has a new mailing  address!   We are working to get contact information on all of our sites updated.    Please update your records:</p>

<p>Yet Another Society d/b/a The Perl Foundation<br/>
340 S <span class="caps">LEMON AVE </span>#6055<br/>
<span class="caps">WALNUT,</span> CA 91789<br/>
<span class="caps">UNITED STATES</span></p>
        
    </div>
    </content>
    <published>2010-08-28T14:15:51Z</published>
    <updated>2010-08-28T14:15:51Z</updated>
    <author>
      <name>Dan Wright</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:news.perlfoundation.org,2010://18.2706</id>
  </entry>
  <entry>
    <title>A month of Test::Builder2</title>
    <link rel="alternate" href="http://use.perl.org/~schwern/journal/40517?from=rss" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I've had a grant open for Test::Builder2 for, oh god over two years now.
Since I started it, Perl 6 has had a release! I think its the second
oldest running dev grant.

I've cleared the decks of other responsibilities and can dedicate
September to, if not finishing, then at least releasing something people
can poke at. First alpha release was supposed to be "two weeks after the
start" ha ha ha! oh god. The design has evolved and simplified greatly in
the intervening two years, but its time to get something the hell out the
door. At least a Test::Builder2 Star if you will.

There's critical components missing. There's no diagnostics, YAML or
otherwise. The issues with nested asserts are still congealing. Plans are
not enforced. Result objects are in the middle of being remodeled...
again. But Test::Builder is using what parts of Test::Builder2 are
usable. Multiple output formats and streams work. Asserts can be nested
in the common, simple cases without having to fiddle with $Level. And you
can hook into various events.

Step one is I'm going to seal up what's there, write docs where they're
missing, and release something.

A release before October or the grant dies.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I've had <a href="http://www.perlfoundation.org/test_builder_2">a grant open for Test::Builder2</a> for, oh god over two years now.  Since I started it, Perl 6 has had a release!  I think its the second oldest running dev grant.</p>
        <p>I've cleared the decks of other responsibilities and can dedicate September to, if not finishing, then at least releasing something people can poke at.  First alpha release was supposed to be "two weeks after the start" ha ha ha! oh god.  The design has evolved and simplified greatly in the intervening two years, but its time to get something the hell out the door.  At least a <a href="http://github.com/schwern/test-more/tree/Test-Builder2">Test::Builder2</a> Star if you will.</p>
        <p>There's critical components missing.  There's no diagnostics, YAML or otherwise.  The issues with nested asserts are still congealing.  Plans are not enforced.  Result objects are in the middle of being remodeled... again.  But Test::Builder is using what parts of Test::Builder2 are usable.  Multiple output formats and streams work.  Asserts can be nested in the common, simple cases without having to fiddle with $Level.  And you can hook into various events.</p>
        <p>Step one is I'm going to seal up what's there, write docs where they're missing, and release something.</p>
        <p>A release before October or the grant dies.</p>
      </div>
    </content>
    <category term="journal"/>
    <published>2010-08-28T04:08:39Z</published>
    <updated>2010-08-28T04:08:39Z</updated>
    <author>
      <name>schwern</name>
    </author>
    <id>tag:perlsphere.net,2006:http://use.perl.org/~schwern/journal/40517?from=rss</id>
  </entry>
  <entry>
    <title>Perl 5.14 Items coming soon</title>
    <link rel="alternate" href="http://www.effectiveperlprogramming.com/blog/531" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">The Perl 5 Porters are currently working on Perl 5.13, the development
track that will end up as Perl 5.14. By reading the perldelta513*
documentation, you can get a peek at what will mostly likely be in the
next maintenance version of Perl. You need to read each of the
perldelta5* in a development series because they only document the
changes in to the previous development release, not the cumulative
changes since the last major release.

Some things you’ll find include:

  * A non-destructive substitution with the /r flag: s///r

  * New ways to specify binary, octal, and hexadecimal numbers.

  * given returns its last evaluated expression (like if-elsif already
    does).

  * srand returns its seed so you can reuse it.

Post to Twitter Post to Delicious Post to Digg Post to Facebook
Post to Reddit</div>
    </summary>
    <content type="html">&lt;p&gt;The Perl 5 Porters are currently working on Perl 5.13, the development track that will end up as Perl 5.14. By reading the &lt;i&gt;perldelta513*&lt;/i&gt; documentation, you can get a peek at what will mostly likely be in the next maintenance version of Perl. You need to read each of the &lt;i&gt;perldelta5*&lt;/i&gt; in a development series because they only document the changes in to the previous development release, not the cumulative changes since the last major release.&lt;/p&gt;
&lt;p&gt;Some things you&amp;#8217;ll find include: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A non-destructive substitution with the &lt;code&gt;/r&lt;/code&gt; flag: &lt;code&gt;s///r&lt;/code&gt;
&lt;li&gt;New ways to specify binary, octal, and hexadecimal numbers.
&lt;li&gt;&lt;code&gt;given&lt;/code&gt; returns its last evaluated expression (like &lt;code&gt;if-elsif&lt;/code&gt; already does).
&lt;li&gt;&lt;code&gt;srand&lt;/code&gt; returns its seed so you can reuse it.
&lt;/ul&gt;
&lt;p align="left"&gt;&lt;a class="tt" href="http://twitter.com/home/?status=Perl+5.14+Items+coming+soon+http://57awp.th8.us" title="Post to Twitter"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-twitter2.png" alt="Post to Twitter"&gt;&lt;/a&gt; &lt;a class="tt" href="http://twitter.com/home/?status=Perl+5.14+Items+coming+soon+http://57awp.th8.us" title="Post to Twitter"&gt; &lt;/a&gt; &lt;a class="tt" href="http://delicious.com/post?url=http://www.effectiveperlprogramming.com/blog/531&amp;amp;title=Perl+5.14+Items+coming+soon" title="Post to Delicious"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious"&gt;&lt;/a&gt; &lt;a class="tt" href="http://delicious.com/post?url=http://www.effectiveperlprogramming.com/blog/531&amp;amp;title=Perl+5.14+Items+coming+soon" title="Post to Delicious"&gt; &lt;/a&gt; &lt;a class="tt" href="http://digg.com/submit?url=http://www.effectiveperlprogramming.com/blog/531&amp;amp;title=Perl+5.14+Items+coming+soon" title="Post to Digg"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg"&gt;&lt;/a&gt; &lt;a class="tt" href="http://digg.com/submit?url=http://www.effectiveperlprogramming.com/blog/531&amp;amp;title=Perl+5.14+Items+coming+soon" title="Post to Digg"&gt; &lt;/a&gt; &lt;a class="tt" href="http://www.facebook.com/share.php?u=http://www.effectiveperlprogramming.com/blog/531&amp;amp;t=Perl+5.14+Items+coming+soon" title="Post to Facebook"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-facebook.png" alt="Post to Facebook"&gt;&lt;/a&gt; &lt;a class="tt" href="http://www.facebook.com/share.php?u=http://www.effectiveperlprogramming.com/blog/531&amp;amp;t=Perl+5.14+Items+coming+soon" title="Post to Facebook"&gt; &lt;/a&gt; &lt;a class="tt" href="http://reddit.com/submit?url=http://www.effectiveperlprogramming.com/blog/531&amp;amp;title=Perl+5.14+Items+coming+soon" title="Post to Reddit"&gt;&lt;img src="http://www.effectiveperlprogramming.com/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit"&gt;&lt;/a&gt; &lt;a class="tt" href="http://reddit.com/submit?url=http://www.effectiveperlprogramming.com/blog/531&amp;amp;title=Perl+5.14+Items+coming+soon" title="Post to Reddit"&gt; &lt;/a&gt;&lt;/p&gt;</content>
    <category term="5.14 administrative note new features"/>
    <published>2010-08-27T21:13:12Z</published>
    <updated>2010-08-27T21:13:12Z</updated>
    <author>
      <name>brian d foy</name>
    </author>
    <id>tag:perlsphere.net,2006:http://www.effectiveperlprogramming.com/?p=531</id>
  </entry>
  <entry>
    <title>Recent CPAN activity</title>
    <link rel="alternate" href="http://jjnapiorkowski.vox.com/library/post/recent-cpan-activity.html?_c=feed-atom-full" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">In no particular order:

This week released two version of Test::DBIx::Class. These were both
minor changes intended to try to reduce the number of test failures
reported. To that end I am now forcing installation of a more recent
version of Data::Dumper. Although I am not using that myself, I do use
Test::Differences which relies on Data::Dumper, but since
Test::Differences doesn't currently specify a version of Data::Dumper it
is possible that if you have an older, buggy Data::Dumper you'd get
meaningless test failures. I submitted a bug to Test::Differences;
hopefully we can fix the problem at the true site of its cause, but for
now my updates should make it easier to install Test::DBIx::Class.

I Also made some minor changes related to making sure the code runs on a
modern version of Moose. So if you have trouble, please let me know :)

Also released was a significant update to
Catalyst::Controller::ActionRole, which leverages some updates in modern
versions of Catalyst so that it now properly matches the functionality in
Catalyst::Controller. Based on this change we were able to release an
update to CatalystX::Declare which uses Catalyst::Controller::ActionRole
as its base controller. Doing this we can now support parameterization in
action roles much more cleanly. Example to follow after I play with this
a bit more :)

Given the new Catalyst::Controller::ActionRole I was finally able to
release Catalyst::ActionRole::BuildDBICResult which is an action role
intended to reduce effort in mapping incoming arguments to rows in your
DBIx::Class managed database. Lastly, I wanted to learn more about Plack,
so did a quick debug panel: Plack::Middleware::Debug::W3CValidate

All in all it was a reasonable productive week for me CPAN wise. Next up
will hopefully be more work on the Plack Catalyst branch.

Thanks!

Read and post comments | Send to a friend</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
            
                <div xmlns:at="http://www.sixapart.com/ns/at">
        <p>In no particular order:</p><p>This week released two version of <a href="http://search.cpan.org/perldoc?Test::DBIx::Class">Test::DBIx::Class</a>.  These were both minor changes intended to try to reduce the number of test failures reported.  To that end I am now forcing installation of a more recent version of <a href="http://search.cpan.org/perldoc?Data::Dumper">Data::Dumper</a>.  Although I am not using that myself, I do use <a href="http://search.cpan.org/perldoc?Test::Differences">Test::Differences</a> which relies on <a href="http://search.cpan.org/perldoc?Data::Dumper">Data::Dumper</a>, but since <a href="http://search.cpan.org/perldoc?Test::Differences">Test::Differences</a> doesn't currently specify a version of <a href="http://search.cpan.org/perldoc?Data::Dumper">Data::Dumpe</a>r it is possible that if you have an older, buggy <a href="http://search.cpan.org/perldoc?Data::Dumper">Data::Dumper</a> you'd get meaningless test failures.  I submitted a bug to <a href="http://search.cpan.org/perldoc?Test::Differences">Test::Differences</a>; hopefully we can fix the problem at the true site of its cause, but for now my updates should make it easier to install T<a href="http://search.cpan.org/perldoc?Test::DBIx::Class">est::DBIx::Class</a>.</p><p>I Also made some minor changes related to making sure the code runs on a modern version of <a href="http://search.cpan.org/perldoc?Moose">Moose</a>.  So if you have trouble, please let me know :)</p><p>Also released was a significant update to <a href="http://search.cpan.org/perldoc?Catalyst::Controller::ActionRole">Catalyst::Controller::ActionRole</a>, which leverages some updates in modern versions of <a href="http://search.cpan.org/perldoc?Catalyst">Catalyst</a> so that it now properly matches the functionality in <a href="http://search.cpan.org/perldoc?Catalyst::Controller">Catalyst::Controller</a>.  Based on this change we were able to release an update to <a href="http://search.cpan.org/perldoc?CatalystX::Declare">CatalystX::Declare</a> which uses <a href="http://search.cpan.org/perldoc?Catalyst::Controller::ActionRole">Catalyst::Controller::ActionRole</a> as its base controller.  Doing this we can now support parameterization in action roles much more cleanly.  Example to follow after I play with this a bit more :)</p><p>Given the new <a href="http://search.cpan.org/perldoc?Catalyst::Controller::ActionRole">Catalyst::Controller::ActionRole</a> I was finally able to release <a href="http://search.cpan.org/%7Ejjnapiork/Catalyst-ActionRole-BuildDBICResult-0.01/lib/Catalyst/ActionRole/BuildDBICResult.pm">Catalyst::ActionRole::BuildDBICResult</a>  which is an action role intended to reduce effort in mapping incoming arguments to rows in your<a href="http://search.cpan.org/perldoc?DBIx::Class"> DBIx::Class</a> managed database.  Lastly, I wanted to learn more about <a href="http://search.cpan.org/perldoc?Plack">Plack</a>, so did a quick debug panel: <a href="http://search.cpan.org/perldoc?Plack::Middleware::Debug::W3CValidate">Plack::Middleware::Debug::W3CValidate</a></p><p>All in all  it was a reasonable productive week for me <a href="http://search.cpan.org">CPAN</a> wise.   Next up will hopefully be more work on the <a href="http://dev.catalystframework.org/svnweb/Catalyst/browse/Catalyst-Runtime/5.80/branches/psgi">Plack Catalyst branch</a>.</p><p>Thanks!</p>    <p> 
    <a href="http://jjnapiorkowski.vox.com/library/post/recent-cpan-activity.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00fa9675c31f00020137a5cccd9c860d?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            
        </div>
    </content>
    <category term="perl ironman catalyst dbix-class dbic plack perl-programming"/>
    <published>2010-08-27T15:22:07Z</published>
    <updated>2010-08-27T15:22:07Z</updated>
    <author>
      <name>John Napiorkowski</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:vox.com,2010-08-27:asset-6a00fa9675c31f00020137a5cccd9c860d</id>
  </entry>
  <entry>
    <title>Perlbuzz news roundup for 2010-08-27</title>
    <link rel="alternate" href="http://feedproxy.google.com/~r/PerlBuzz/~3/0IMDsdKCaoA/perlbuzz-news-roundup-for-2010-08-27.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">These links are collected from the Perlbuzz Twitter feed. If you have
suggestions for news bits, please mail me at andy@perlbuzz.com.

  * So you want to write a Perl 6 module? (ttjjss.wordpress.com)

  * What is the Japan Perl Association and what does it do? (mt.endeworks.jp)

  * My first patch to Rakudo Perl 6: (mail-archive.com)

  * A reminder to HR folks: It's Perl, not PERL. (jobs.perl.org)

  * David Golden cuts through some Rakudo Star snark (dagolden.com)

  * I'm glad to hear "Rakudo is slow!" (perlbuzz.com)

  * Rakudo Star means Perl 6 questions are on the rise at Perlmonks (perlgeek.de)

  * Perl is not an acronym (perlbuzz.com)

  * 45m of video interview w/Larry Wall, creator of Perl
    http://bigthink.com/larrywall (via @theory and @sachmet)

  * Top three languages at github: Ruby, JavaScript, Perl (r-chart.com)

  * CPAN Testers must convert from email to HTTP by Sep 1st (log.perl.org)

  * First impressions of Perl 6 from blog "Mad, Beautiful Ideas", which
    seems appropriate for Perl 6 (blog.foxxtrot.net)

  * Devel::CheckLib needs a new maintainer (blogs.perl.org)

  * Rakudo bugs are love (use.perl.org)

  * HTTP::BrowserDetect has been freshly updated (blogs.perl.org)

  * What's on your to-do list? Here's mine: (perlbuzz.com)

  * pudge on the uncertain future of use.perl.org (use.perl.org)

  * The 2010 White Camel awards (blogs.perl.org)

  * Perlmonks poll: My first impression of Rakudo Star... (perlmonks.org)

  * Vim 7.3 supports Perl 6, adds Perl 5 improvements (perlbuzz.com)

  * Improving Perl sub detection in git diffs (blogs.perl.org)

  * Perl Foundation news site gets a redesign (news.perlfoundation.org)

  * Switching to Dist::Zilla: A usage report (blogs.perl.org)

  * Temporarily delete hash keys or array elements with "delete local" (effectiveperlprogramming.com)

  * Run PHP tests in your Perl test suite (perlbuzz.com)

  * What is the "Cool" class in Perl 6? (perlgeek.de)

  * I'm playing with the ack.vim plugin. I like it much. (vim.org)

  * Alien::SVN has a new owner, for those of you still hooking into
    Subversion (use.perl.org)

  * WWW::Salesforce gets a long-awaited update (blogs.perl.org)

  * Don't discount the value of indirect PR. A mention of Perl 6 is a
    mention of Perl 6. (pcworld.com)

  * Which Perl XML module should I use to...? (blogs.perl.org)

  * Video of Tim Bunce's talk about DBDI for Perl 6: (blip.tv)

  * Videos from YAPC::EU available (Thanks @sachmet) (conferences.yapceurope.org)

  * Allison Randal is now working full time at Ubuntu (allisonrandal.com)

  * Non-technical strategies for getting people on board with
    technological change (everythingsysadmin.com)

  * Useful side effects of Perl testing culture (xrl.us)

  * Idiomatic Perl 6 (use.perl.org)

[IMAGE] [IMAGE] [IMAGE] [IMAGE][IMAGE]</div>
    </summary>
    <content type="html">
        &lt;p&gt;
These links are collected from the
&lt;a href="http://twitter.com/perlbuzz"&gt;Perlbuzz Twitter feed&lt;/a&gt;.
If you have suggestions for news bits, please mail me at
&lt;a href="mailto:andy@perlbuzz.com"&gt;andy@perlbuzz.com&lt;/a&gt;.
&lt;/p&gt;

&lt;ul&gt;

&lt;li&gt;So you want to write a Perl 6 module? (&lt;a href="http://ttjjss.wordpress.com/2010/08/09/so-you-want-to-write-a-perl-6-module/"&gt;ttjjss.wordpress.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;What is the Japan Perl Association and what does it do? (&lt;a href="http://mt.endeworks.jp/d-6/2010/07/how-jpa-works-what-jpa-does-in.html"&gt;mt.endeworks.jp&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;My first patch to Rakudo Perl 6: (&lt;a href="http://www.mail-archive.com/perl6-all&amp;lt;a href=&amp;quot;http://twitter.com/perl&amp;quot;&amp;gt;@perl&amp;lt;/a&amp;gt;.org/msg89795.html"&gt;mail-archive.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;A reminder to HR folks: It's Perl, not PERL. (&lt;a href="http://jobs.perl.org/"&gt;jobs.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;David Golden cuts through some Rakudo Star snark (&lt;a href="http://www.dagolden.com/index.php/947/thoughts-on-perl-6-hype-and-backlash/"&gt;dagolden.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;I'm glad to hear "Rakudo is slow!" (&lt;a href="http://perlbuzz.com/2010/08/im-glad-to-hear-rakudo-is-slow.html"&gt;perlbuzz.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Rakudo Star means Perl 6 questions are on the rise at Perlmonks (&lt;a href="http://perlgeek.de/blog-en/perl-6/perlmonks-questions.html"&gt;perlgeek.de&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Perl is not an acronym (&lt;a href="http://perlbuzz.com/2010/08/perl-is-not-an-acronym.html"&gt;perlbuzz.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;45m of video interview w/Larry Wall, creator of Perl http://bigthink.com/larrywall (via &lt;a href="http://twitter.com/theory"&gt;@theory&lt;/a&gt; and &lt;a href="http://twitter.com/sachmet"&gt;@sachmet&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Top three languages at github: Ruby, JavaScript, Perl (&lt;a href="http://www.r-chart.com/2010/08/github-stats-on-programming-languages.html"&gt;r-chart.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;CPAN Testers must convert from email to HTTP by Sep 1st (&lt;a href="http://log.perl.org/2010/08/cpan-testers-email-submission-interface-going-away-september-1st.html"&gt;log.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;First impressions of Perl 6 from blog "Mad, Beautiful Ideas", which seems appropriate for Perl 6 (&lt;a href="http://blog.foxxtrot.net/2010/08/perl6-first-impressions.html"&gt;blog.foxxtrot.net&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Devel::CheckLib needs a new maintainer (&lt;a href="http://blogs.perl.org/users/david_cantrell/2010/08/develchecklib-needs-a-new-maintainer.html"&gt;blogs.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Rakudo bugs are love (&lt;a href="http://use.perl.org/~masak/journal/40490"&gt;use.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;HTTP::BrowserDetect has been freshly updated (&lt;a href="http://blogs.perl.org/users/olaf_alders/2010/08/httpbrowserdetect-for-all-of-your-useragent-parsing-needs.html"&gt;blogs.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;What's on your to-do list? Here's mine: (&lt;a href="http://perlbuzz.com/2010/08/whats-on-your-to-do-list.html"&gt;perlbuzz.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;pudge on the uncertain future of use.perl.org (&lt;a href="http://use.perl.org/~pudge/journal/40493"&gt;use.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;The 2010 White Camel awards (&lt;a href="http://blogs.perl.org/users/brian_d_foy/2010/08/the-2010-white-camel-awards.html"&gt;blogs.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Perlmonks poll: My first impression of Rakudo Star... (&lt;a href="http://www.perlmonks.org/?node_id=852336"&gt;perlmonks.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Vim 7.3 supports Perl 6, adds Perl 5 improvements (&lt;a href="http://perlbuzz.com/2010/08/vim-73-supports-perl-6.html"&gt;perlbuzz.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Improving Perl sub detection in git diffs (&lt;a href="http://blogs.perl.org/users/aevar_arnfjor_bjarmason/2010/08/lets-add-git-userdiff-defaults-for-perl-and-perl-6.html"&gt;blogs.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Perl Foundation news site gets a redesign (&lt;a href="http://news.perlfoundation.org/"&gt;news.perlfoundation.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Switching to Dist::Zilla: A usage report (&lt;a href="http://blogs.perl.org/users/job_van_achterberg/2010/08/switching-to-distzilla---a-usage-report.html"&gt;blogs.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Temporarily delete hash keys or array elements with "delete local" (&lt;a href="http://www.effectiveperlprogramming.com/blog/504"&gt;effectiveperlprogramming.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Run PHP tests in your Perl test suite (&lt;a href="http://perlbuzz.com/2010/08/run-php-tests-in-your-perl-test-suite.html"&gt;perlbuzz.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;What is the "Cool" class in Perl 6? (&lt;a href="http://perlgeek.de/blog-en/perl-6/cool.html"&gt;perlgeek.de&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;I'm playing with the ack.vim plugin. I like it much. (&lt;a href="http://www.vim.org/scripts/script.php?script_id=2572"&gt;vim.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Alien::SVN has a new owner, for those of you still hooking into Subversion (&lt;a href="http://use.perl.org/~schwern/journal/40503"&gt;use.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;WWW::Salesforce gets a long-awaited update (&lt;a href="http://blogs.perl.org/users/phred/2010/08/new-wwwsalesforce-release-and-maintainer.html"&gt;blogs.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Don't discount the value of indirect PR. A mention of Perl 6 is a mention of Perl 6. (&lt;a href="http://www.pcworld.com/businesscenter/article/203671/vim_editor_updated_with_modern_language_support.html"&gt;pcworld.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Which Perl XML module should I use to...? (&lt;a href="http://blogs.perl.org/users/brian_d_foy/2010/08/which-perl-xml-module-should-i-use-to.html"&gt;blogs.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Video of Tim Bunce's talk about DBDI for Perl 6: (&lt;a href="http://blip.tv/file/3973550"&gt;blip.tv&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Videos from YAPC::EU available (Thanks &lt;a href="http://twitter.com/sachmet"&gt;@sachmet&lt;/a&gt;) (&lt;a href="http://conferences.yapceurope.org/ye2010/news/632"&gt;conferences.yapceurope.org&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Allison Randal is now working full time at Ubuntu (&lt;a href="http://allisonrandal.com/2010/08/20/ubuntu-ta-intro/"&gt;allisonrandal.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Non-technical strategies for getting people on board with technological change (&lt;a href="http://everythingsysadmin.com/2010/08/non-technical-strategies.html"&gt;everythingsysadmin.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Useful side effects of Perl testing culture (&lt;a href="http://xrl.us/bhxgx3"&gt;xrl.us&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Idiomatic Perl 6 (&lt;a href="http://use.perl.org/~masak/journal/40516"&gt;use.perl.org&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

        
    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=0IMDsdKCaoA:MUNKxxrgxf0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=yIl2AUoC8zA"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=0IMDsdKCaoA:MUNKxxrgxf0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=0IMDsdKCaoA:MUNKxxrgxf0:F7zBnMyn0Lo"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=0IMDsdKCaoA:MUNKxxrgxf0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=0IMDsdKCaoA:MUNKxxrgxf0:V_sGLiPBpWU"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=0IMDsdKCaoA:MUNKxxrgxf0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=qj6IDK7rITs"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PerlBuzz/~4/0IMDsdKCaoA"&gt;</content>
    <category term="CPAN Parrot Perl 5 Perl 6 Perl Foundation"/>
    <published>2010-08-27T15:11:48Z</published>
    <updated>2010-08-27T15:11:48Z</updated>
    <author>
      <name>Andy Lester</name>
    </author>
    <id>tag:perlsphere.net,2006:tag:perlbuzz.com,2010://1.804</id>
  </entry>
  <entry>
    <title>Programming Languages Are Not Zero Sum</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/not-zero-sum.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">From Wikipedia, the free encyclopedia:

  In game theory and economic theory, zero-sum describes a situation in
  which a participant's gain or loss is exactly balanced by the losses
  or gains of the other participant(s). If the total gains of the
  participants are added up, and the total losses are subtracted, they
  will sum to zero.

Being advocate, implementor, tester and co-designer of a new programming
language, I often hear objections along the lines of you are killing
$other_programming_language, combined with a mixture of fear and
resentment. People are afraid that having a new player on the market will
decrease market share of their own, favorite programming language.

While I can understand these thinking patterns, there is no reason for
concern. The market for programming languages is not a zero-sum
situation. While I don't have hard data, I have the impression that the
programming job sector is growing, and the US government expects it to
grow further, too.

Certainly the growth of world population sets a rapidly increasing
baseline, and even if we assume a constant percentage of all people
related to programming in some way, the total number of programmers
rises, and will continue for quite some time.

(I'm pointing to some resources about programming jobs, and I fully
realize that it's not the same as number of overall programmers; but it's
easier to get data for jobs, and I do think that the general trend
statements are true for both).

So as long as the total number of programmers increases, a decrease in
relative market share doesn't automatically mean a loss. In fact the job
trends show an increase for "scripting" languages, and while Ruby is
certainly the winner in terms of growth, Python, Perl and PHP win too!

Non-job data shows for example a noisy but steady growth of uploads to
the Comprehensive Perl Archive Network (CPAN) -- data from a programming
language that is often perceived as a loser of ruby's and python's
success.

A recent Linux distribution trend analysis fell into the same trap: it
shows relative numbers of search terms, and talks about a decline for all
distributions except Ubuntu. Again I don't have hard numbers (the mirror
infrastructure of most Linux distributions makes it nearly impossible to
get accurate download counts), but I haven't seen any evidence that total
usage numbers of any of the Linux distributions actually decreased.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>From <a href="http://en.wikipedia.org/wiki/Zero-sum">Wikipedia, the free
    encyclopedia</a>:</p>

<blockquote><p>
    In game theory and economic theory, zero-sum describes a situation
    in which a participant's gain or loss is exactly balanced by the losses or
    gains of the other participant(s). If the total gains of the participants
    are added up, and the total losses are subtracted, they will sum to zero.
</p></blockquote>

<p>Being advocate, implementor, tester and co-designer of a <a href="http://perl6.org/">new programming language</a>, I often hear objections
along the lines of <em>you are killing <a href="http://www.perl.org/">$other_programming_language</a></em>, combined
with a mixture of fear and resentment. People are afraid that having a new
player on the market will decrease
market share of their own, favorite programming language.</p>

<p>While I can understand these thinking patterns, there is no reason for
concern. The market for programming languages is not a zero-sum situation.
While I don't have hard data, I have the impression that the programming job
sector is growing, and <a href="http://www.bls.gov/oco/ocos303.htm#projections_data">the US
government expects it to grow</a> further, too.</p>

<p>Certainly the <a href="http://upload.wikimedia.org/wikipedia/commons/7/77/World-Population-1800-2100.png">growth
of world population</a> sets a rapidly increasing baseline, and even if we
assume a constant percentage of all people related to programming in some way,
the total number of programmers rises, and will continue for quite some
time.</p>

<p>(I'm pointing to some resources about programming jobs, and I fully realize that
it's not the same as number of overall programmers; but it's easier to get
data for jobs, and I do think that the general trend statements are true for
both).</p>

<p>So as long as the total number of programmers increases, a decrease in
relative market share doesn't automatically mean a loss. In fact <a href="http://duartes.org/gustavo/blog/post/programming-language-jobs-and-trends">the
job trends show an increase for "scripting" languages</a>, and while Ruby is
certainly the winner in terms of growth, Python, Perl and PHP win too!</p>

<p>Non-job data shows for example a <a href="http://stats.cpantesters.org/graphs12.html">noisy but steady growth
of uploads to the Comprehensive Perl Archive Network (CPAN)</a> -- data from a
programming language that is often perceived as a loser of ruby's and python's
success.</p>

<p>A recent <a href="http://linuxtrends.com/linux-distribution-popularity-trends/">Linux
distribution trend analysis</a> fell into the same trap: it shows
<strong>relative</strong> numbers of search terms, and talks about a decline
for all distributions except Ubuntu. Again I don't have hard numbers (the
mirror infrastructure of most Linux distributions makes it nearly impossible
to get accurate download counts), but I haven't seen any evidence that total
usage numbers of any of the Linux distributions actually decreased.</p>


</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/not-zero-sum.html</id>
  </entry>
  <entry>
    <title> Bryar security hole </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_bryar-security-hole" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Someone on IRC reported a bug in Bryar. Namely that a Naughty Person can
exploit the feature that notifies you of blog-spam by email to execute
arbitrary code on your machine, as the user you run Bryar under.

A patched release is on the way to the CPAN, and you are strongly urged
to upgrade.</div>
    </summary>
    <content type="text">Someone on IRC reported a bug in Bryar.  Namely that a Naughty Person can exploit the feature that notifies you of blog-spam by email to execute arbitrary code on your machine, as the user you run Bryar under.&lt;p&gt;A patched release is on the way to the CPAN, and you are strongly urged to upgrade.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_bryar-security-hole</id>
  </entry>
  <entry>
    <title> YAPC::Europe 2007 travel plans </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2007--travel-plans" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I'm going to Vienna by train for YAPC::Europe. If you want to join me
you'll need to book in advance, and probably quite some way in advance as
some of these trains apparently get fully booked.

arr

dep

date

Waterloo

1740

Fri 24 Aug

Paris Nord

2117

Paris Est

2245

Munich

0859

0928

Sat 25 Aug

Vienna

1335

The first two legs of that are second class, cos first wasn't available
on Eurostar (being a Friday evening it's one of the commuter Eurostars
and gets booked up months and months in advance) and was way too spendy
on the sleeper to Munich. Upgrading to first class from Munich to Vienna
is cheap, so I have.

Coming back it's first class all the way cos upgrading was nearly free
...

arr

dep

date

Vienna

0930

Fri 31 Aug

Zurich

1820

Zurich

1402

Sun 2 Sep

Paris Est

1834

Paris Nord

2013

Waterloo

2159

Don't even think about trying to book online or over the phone, or at the
Eurostar ticket office at Waterloo. Your best bet is to go to the Rail
Europe shop on Picadilly, opposite the Royal Academy and next to
Fortnums.</div>
    </summary>
    <content type="text">I'm going to Vienna by train for &lt;a href="http://vienna.yapceurope.org/ye2007/index.html"&gt;YAPC::Europe&lt;/a&gt;.  If you want to join me you'll need to book in advance, and probably quite some way in advance as some of these trains apparently get fully booked.&lt;p&gt;&lt;table border="1"&gt;
  &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;th&gt;arr&lt;/th&gt;&lt;th&gt;dep&lt;/th&gt;&lt;th&gt;date&lt;/th&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Waterloo&lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;1740&lt;/td&gt;&lt;td&gt;Fri 24 Aug&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Paris Nord&lt;/th&gt;&lt;td&gt;2117&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Paris Est&lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;2245&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Munich&lt;/th&gt;&lt;td&gt;0859&lt;/td&gt;&lt;td&gt;0928&lt;/td&gt;&lt;td&gt;Sat 25 Aug&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Vienna&lt;/th&gt;&lt;td&gt;1335&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;p&gt;The first two legs of that are second class, cos first wasn't available on Eurostar (being a Friday evening it's one of the commuter Eurostars and gets booked up months and months in advance) and was way too spendy on the sleeper to Munich.  Upgrading to first class from Munich to Vienna is cheap, so I have.&lt;p&gt;Coming back it's first class all the way cos upgrading was nearly free ...&lt;p&gt;&lt;table border="1"&gt;
  &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;th&gt;arr&lt;/th&gt;&lt;th&gt;dep&lt;/th&gt;&lt;th&gt;date&lt;/th&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Vienna&lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;0930&lt;/td&gt;&lt;td&gt;Fri 31 Aug&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Zurich&lt;/th&gt;&lt;td&gt;1820&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Zurich&lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;1402&lt;/td&gt;&lt;td&gt;Sun 2 Sep&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Paris Est&lt;/th&gt;&lt;td&gt;1834&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Paris Nord&lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;2013&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;th align="right"&gt;Waterloo&lt;/th&gt;&lt;td&gt;2159&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;p&gt;Don't even think about trying to book online or over the phone, or at the Eurostar ticket office at Waterloo.  Your best bet is to go to the Rail Europe shop on Picadilly, opposite the Royal Academy and next to Fortnums.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2007--travel-plans</id>
  </entry>
  <entry>
    <title> Perl isn't dieing </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_perl-isnt-dying" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Perl isn't dieing, but it tells me that it wishes it was. Last night it
went out on the piss with Python and Ruby (PHP was the designated driver)
and it did rather too many cocktails. It isn't quite sure what happened,
but it woke up in the gutter in a puddle of its own fluids and its head
hurts a lot.

It asked me to ask you all to keep the volume down.</div>
    </summary>
    <content type="text">Perl isn't dieing, but it tells me that it wishes it was.  Last night it went out on the piss with Python and Ruby (PHP was the designated driver) and it did rather too many cocktails.  It isn't quite sure what happened, but it woke up in the gutter in a puddle of its own fluids and its head hurts a &lt;em&gt;lot&lt;/em&gt;.&lt;p&gt;It asked me to ask you all to keep the volume down.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_perl-isnt-dying</id>
  </entry>
  <entry>
    <title> Thanks, Yahoo! </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_thanks-yahoo" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">[originally posted on Apr 3 2008]

I'd like to express my warm thanks to the lovely people at Yahoo and in
particular to their bot-herders. Until quite recently, their web-crawling
bots had most irritatingly obeyed robot exclusion rules in the robots.txt
file that I have on CPANdeps. But in the last couple of weeks they've got
rid of that niggling little exclusion so now they're indexing all of the
CPAN's dependencies through my site! And for the benefit of their
important customers, they're doing it nice and quickly - a request every
few seconds instead of the pedestrian once every few minutes that gentler
bots use.

Unfortunately, because generating a dependency tree takes more time than
they were allowing between requests, they were filling up my process
table, and all my memory, and eating all the CPU, and the only way to get
back into the machine was by power-cycling it. So it is with the deepest
of regrets that I have had to exclude them.

Cunts.

[update] For fuck's sake, they're doing it again from a different
netblock!</div>
    </summary>
    <content type="text">[originally posted on Apr  3  2008]&lt;p&gt;I'd like to express my warm thanks to the lovely people at Yahoo and in particular to their bot-herders.  Until quite recently, their web-crawling bots had most irritatingly obeyed robot exclusion rules in the robots.txt file that I have on &lt;a href="http://cpandeps.cantrell.org.uk/"&gt;CPANdeps&lt;/a&gt;.  But in the last couple of weeks they've got rid of that niggling little exclusion so now they're indexing all of the CPAN's dependencies through my site!  And for the benefit of their important customers, they're doing it nice and quickly - a request every few seconds instead of the pedestrian once every few minutes that gentler bots use.&lt;p&gt;Unfortunately, because generating a dependency tree takes more time than they were allowing between requests, they were filling up my process table, and all my memory, and eating all the CPU, and the only way to get back into the machine was by power-cycling it.  So it is with the deepest of regrets that I have had to exclude them.&lt;p&gt;&lt;a href="http://www.yahoo.com/"&gt;Cunts&lt;/a&gt;.&lt;p&gt;[update]  For fuck's sake, they're doing it again from a different netblock!
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_thanks-yahoo</id>
  </entry>
  <entry>
    <title>What is the "Cool" class in Perl 6?</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/cool.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">In Perl, subroutine and operator names determine what happens, usually
not the type of the arguments. Instead the arguments are coerced to a
type on which the operation makes sense:

say uc 34;      # coerces 34 to a string, and upper-cases itsay 1 + "2";    # converts "2" to a number before adding

To make things more extensible, the uc function re-dispatches to the uc
method on its argument. So for the example above to work, we need an uc
function in Int. And in Array, so that @a.uc works. And so on.

The original approach was to stuff all these methods into Any, the base
class of the object hierarchy. Which kinda worked, but also meant that
all user-defined classes ended up having some few hundreds methods to
start with. Not good.

These days, the type Cool fills this niche: most built-in types (all that
are meant to be used in that polymorphic way) inherit from Cool, so the
uc method is actually defined in class Cool, coerces to string, and then
re-dispatches to the internal logic that actually does the upper-casing.

The name either stands for Convenient object oriented loopback, or just
expresses that that most built-ins are cool with an argument of that
type.

If users want to write a type that can be used like a built-in type now
just inherit from Cool, and define coercion methods to other built-in
types. If the types don't inherit from Cool, they are more light-weight,
and less magic. There's more than one way to do it.

Cool is a class (and not a role), because classes are mutable; so if you
want to inject behavior into nearly all built-in types, augmenting Cool
is an option (though usually considered evil, and should not be done
lightly).</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>In Perl, subroutine and operator names determine what happens, usually not
the type of the arguments. Instead the arguments are coerced to a type on
which the operation makes sense:</p>

<pre>
<span class="synIdentifier">say</span> <span class="synIdentifier">uc</span> <span class="synConstant">34</span><span class="synStatement">;</span>      <span class="synComment"># coerces 34 to a string, and upper-cases it</span>
<span class="synIdentifier">say</span> <span class="synConstant">1</span> <span class="synStatement">+</span> <span class="synSpecial">"</span><span class="synConstant">2</span><span class="synSpecial">"</span><span class="synStatement">;</span>    <span class="synComment"># converts "2" to a number before adding</span>
</pre>

<p>To make things more extensible, the <code>uc</code> function re-dispatches
to the <code>uc</code> method on its argument. So for the example above to
work, we need an <code>uc</code> function in Int. And in Array, so that
<code>@a.uc</code> works. And so on.</p>

<p>The original approach was to stuff all these methods into <code>Any</code>,
the base class of the object hierarchy. Which kinda worked, but also meant
that all user-defined classes ended up having some few hundreds methods to
start with. Not good.</p>

<p>These days, the type <code>Cool</code> fills this niche: most built-in types
(all that are meant to be used in that polymorphic way) inherit from Cool, so
the <code>uc</code> method is actually defined in class <code>Cool</code>,
coerces to string, and then re-dispatches to the internal logic that actually
does the upper-casing.</p>

<p>The name either stands for <em><strong>C</strong>onvenient
    <strong>o</strong>bject <strong>o</strong>riented
    <strong>l</strong>oopback</em>, or just expresses that that most
built-ins are cool with an argument of that type.</p>

<p>If users want to write a type that can be used like a built-in type now
just inherit from <code>Cool</code>, and define coercion methods to other
built-in types. If the types don't inherit from <code>Cool</code>, they are
more light-weight, and less magic. There's more than one way to do it.</p>

<p><code>Cool</code> is a class (and not a role), because classes are mutable;
so if you want to inject behavior into nearly all built-in types, augmenting
<code>Cool</code> is an option (though usually considered evil, and should not
be done lightly).</p>


</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/cool.html</id>
  </entry>
  <entry>
    <title> Module pre-requisites analyser </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_cpandeps-release" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">As a service to module authors, here is a tool to show a module's
pre-requisites and the test results from the CPAN testers. So before you
rely on something working as a pre-requisite for your code, have a look
to see how reliable it and its dependencies are.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">As a service to module authors, <a href="http://cpandeps.cantrell.org.uk/">here</a> is a tool to show a module's pre-requisites and the test results from the CPAN testers.  So before you rely on something working as a pre-requisite for your code, have a look to see how reliable it and <em>its</em> dependencies are.
</div>
    </content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_cpandeps-release</id>
  </entry>
  <entry>
    <title>Pascal's Triangle in Perl 6</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/pascal-triangle.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Today on IRC, Larry Wall showed this piece of Perl 6 code, which he wrote
for Rosetta Code:

sub pascal { [1], -&gt; @p { [0, @p Z+ @p, 0] } ... * };say pascal[^10].perl# output (reformatted for easy readbility):# ([1],#  [1, 1],#  [1, 2, 1],#  [1, 3, 3, 1],#  [1, 4, 6, 4, 1],#  [1, 5, 10, 10, 5, 1],#  [1, 6, 15, 20, 15, 6, 1],#  [1, 7, 21, 35, 35, 21, 7, 1],#  [1, 8, 28, 56, 70, 56, 28, 8, 1],#  [1, 9, 36, 84, 126, 126, 84, 36, 9, 1])

That's Pascal's triangle, generated in one line of Perl 6.

The ... is the series operator, which generates lists by feeding the
previous value(s) (here always one array) to the generating block on its
left, until it reaches the goal on the right (in this case "whatever",
which means it returns a lazy, infinite list).

So for example if the previous item was the array [1, 2, 1], the code
block evaluates 0, 1, 2, 1 Z+ 1, 2, 1, 0.

Z is the zip operator, Z+ is pairwise addition (ie adding the pairs that
the zip operator produced). In our example that leads to 0+1, 1+2, 2+1,
1+0 or 1, 3, 3, 1.

It takes a while to get used to the meta operators and the series
operator, but once you've understood them, you can do pretty neat things
with them.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>Today on IRC, Larry Wall showed this piece of Perl 6 code, which he wrote
for <a href="http://rosettacode.org/wiki/Pascal%27s_triangle#Perl_6">Rosetta
Code</a>:</p>

<pre>
<span class="synStatement">sub</span> pascal { [<span class="synConstant">1</span>]<span class="synStatement">,</span> <span class="synStatement">-&gt;</span> <span class="synIdentifier">@p</span> { [<span class="synConstant">0</span><span class="synStatement">,</span> <span class="synIdentifier">@p</span> <span class="synStatement">Z+</span> <span class="synIdentifier">@p</span><span class="synStatement">,</span> <span class="synConstant">0</span>] } <span class="synStatement">...</span> <span class="synStatement">*</span> }<span class="synStatement">;</span>
<span class="synIdentifier">say</span> pascal[<span class="synStatement">^</span><span class="synConstant">10</span>]<span class="synStatement">.</span><span class="synIdentifier">perl</span>
<span class="synComment"># output (reformatted for easy readbility):</span>
<span class="synComment"># ([1],</span>
<span class="synComment">#  [1, 1],</span>
<span class="synComment">#  [1, 2, 1],</span>
<span class="synComment">#  [1, 3, 3, 1],</span>
<span class="synComment">#  [1, 4, 6, 4, 1],</span>
<span class="synComment">#  [1, 5, 10, 10, 5, 1],</span>
<span class="synComment">#  [1, 6, 15, 20, 15, 6, 1],</span>
<span class="synComment">#  [1, 7, 21, 35, 35, 21, 7, 1],</span>
<span class="synComment">#  [1, 8, 28, 56, 70, 56, 28, 8, 1],</span>
<span class="synComment">#  [1, 9, 36, 84, 126, 126, 84, 36, 9, 1])</span>
</pre>

<p>That's <a href="http://en.wikipedia.org/wiki/Pascal%27s_triangle">Pascal's
triangle</a>, generated in one line of Perl 6.</p>

<p>The <code>...</code> is the series operator, which generates lists by
feeding the previous value(s) (here always one array) to the generating
block on its left, until it reaches the goal on the right (in this case
"whatever", which means it returns a lazy, infinite list).</p>

<p>So for example if the previous item was the array <code>[1, 2, 1]</code>,
the code block evaluates <code>0, 1, 2, 1 Z+ 1, 2, 1, 0</code>. </p>

<p><code>Z</code> is the zip operator, <code>Z+</code> is pairwise addition
(ie adding the pairs that the zip operator produced). In our example that
leads to <code>0+1, 1+2, 2+1, 1+0</code> or <code>1, 3, 3, 1</code>.</p>

<p>It takes a while to get used to the meta operators and the series operator,
but once you've understood them, you can do pretty neat things with them.</p>


</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/pascal-triangle.html</id>
  </entry>
  <entry>
    <title>What is "Modern Perl"?</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-tips/what-is-modern-perl.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">These days you often hear term Modern Perl, as something new(ish), and
much improved over the old ways.

But what is it exactly? Well, there's no proper definition, but here is
what that term means to me:

It's a set of tools, ideas and attitudes that help you to write better
Perl programs, and allows you to have more fun while writing them.

Here are some aspects of Modern Perl

  * Testing: Most modern Perl modules have extensive test suites, that
    make development sane and robust

  * Some built-ins now come with safer forms: the three-argument form of
    open() allows you to open files safely with arbitrary characters in
    them, without any extra precautions. Lexical file handles make things
    safer and easier too.

  * use strict; use warnings;

  * Proper OO: with Perl 6 and with Moose in Perl 5, we have good object
    systems, that require less low-level fiddling than the standard Perl
    5 object system

  * Following Best Practices

  * (For open source projects) Liberally handing out commit privileges.
    The source is stored in a version control system anyway, so
    low-quality changes or vandalism can simply be reverted (but that
    doesn't happen often in practice).

  * Caring about marketing: do tell people that you built something cool
    and useful

  * Small handy modules such as List::Util and Try::Tiny

  * Development tools such as Devel::Cover and Devel::NYTProf

  * (update) perlbrew and local::lib to help maintain your own perl
    installation and locally installed modules.

All of these techniques help to write scalable Perl programs by making
proper encapsulation much easier, or by avoiding common errors,
identifying performance bottlenecks etc.

Update: after watching some discussions about this post in various media,
I should add a few more tools that I forgot about earlier:

  * Devel::REPL, Read-Evaluation-Print Loop

  * Perl::Critic, a code quality and style tester

  * DDBIx::Class, a modern and very popular object relational mapper

  * Catalyst, a web framework based on the MVC pattern</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>These days you often hear term <em>Modern Perl</em>, as something new(ish),
and much improved over the old ways.</p>

<p>But what is it exactly? Well, there's no proper definition, but here is
what that term means to me:</p>

<p>It's a set of tools, ideas and attitudes that help you to write better Perl
programs, and allows you to have more fun while writing them.</p>

<p>Here are some aspects of Modern Perl</p>

<ul>
    <li>Testing: Most modern Perl modules have extensive test suites, that
    make development sane and robust</li>
    <li>Some built-ins now come with safer forms: the <a href="http://perldoc.perl.org/functions/open.html">three-argument form
    of open()</a> allows you to open files safely with arbitrary characters in
    them, without any extra precautions. Lexical file handles make things safer
    and easier too.</li>
    <li><code>use <a href="http://perldoc.perl.org/strict.html">strict</a>; use <a href="http://perldoc.perl.org/perllexwarn.html">warnings</a>;</code></li>
    <li>Proper OO: with Perl 6 and with <a href="http://www.iinteractive.com/moose/">Moose</a> in Perl 5, we have
    good object systems, that require less low-level fiddling than the
    standard Perl 5 object system</li>
    <li>Following <a href="http://www.linuxjournal.com/article/8567">Best
        Practices</a></li>
    <li>(For open source projects) Liberally handing out commit privileges.
    The source is stored in a version control system anyway, so low-quality
    changes or vandalism can simply be reverted (but that doesn't happen often
    in practice).</li>
    <li>Caring about marketing: do tell people that you built something cool
    and useful</li>
    <li>Small handy modules such as <a href="http://search.cpan.org/perldoc?List::Util">List::Util</a> and <a href="http://search.cpan.org/perldoc?Try::Tiny">Try::Tiny</a></li>
    <li>Development tools such as <a href="http://search.cpan.org/perldoc?Devel::Cover">Devel::Cover</a>
    and <a href="http://search.cpan.org/perldoc?Devel::NYTProf">Devel::NYTProf</a></li>
    <li>(update) <a href="http://search.cpan.org/dist/App-perlbrew/">perlbrew</a> and <a href="search.cpan.org/perldoc/local::lib">local::lib</a> to help
        maintain your own perl installation and locally installed
        modules.</li>
</ul>

<p>All of these techniques help to write scalable Perl programs by making
proper encapsulation much easier, or by avoiding common errors, identifying
performance bottlenecks etc.</p>

<p><strong>Update:</strong> after watching some discussions about this post in
various media, I should add a few more tools that I forgot about earlier:</p>

<ul>
    <li><a href="http://search.cpan.org/perldoc?Devel::REPL">Devel::REPL</a>,
    Read-Evaluation-Print Loop</li>
    <li><a href="http://search.cpan.org/perldoc?Perl::Critic">Perl::Critic</a>,
        a code quality and style tester</li>
    <li><a href="http://search.cpan.org/perldoc?DBIx::Class">DDBIx::Class</a>,
        a modern and very popular object relational mapper</li>
    <li><a href="http://search.cpan.org/perldoc?Catalyst">Catalyst</a>,
        a web framework based on the MVC pattern</li>
</ul>

 
</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-tips/what-is-modern-perl.html</id>
  </entry>
  <entry>
    <title>This Week's Contribution to Perl 6 Week 8: Implement $*ARGFILES for Rakudo</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/contribute-now-argfiles.html" type="text/html"/>
    <summary type="text">For this week's contribution to Perl 6 we ask you to implement the
$*ARGFILES special variable (and underlying object) for Rakudo.

(Introduction to this series of challenges)


Background
----------

In Perl 5, there is a "magic" way to iterate over input: while (my $line
= &lt;&gt;) { ... }. This reads from standard input if no command line
arguments were provided. If there are command line arguments, they are
taken as file names, and &lt;&gt; iterates over the contents of these files.

In Perl 6 this magic is performed with the $*ARGFILES special variable.
Please implement it!

To do that, you have to understand how file reading works in Perl 6. Once
you have a file handle, there are two ways to read lines: either by
calling $handle.get, which returns just one line, or by calling
$handle.lines, which returns a (lazy) list of all the remaining lines.

You can obtain the command line arguments from @*ARGS, open a file with
my $handle = open $filename; for reading; And finally you can use
lines('filename') to read all lines from a file.


What you can do
---------------

Implement a backend class for $*ARGFILES. You can do that in normal Perl
6 code, no need to change the actual compiler. Once that's done, we will
plug it into Rakudo. Your code might look like this:

class IO::ArgFiles {
    has @!filenames;    method get() { ... }
    method lines() { ... }
    method filename() {
        # return the current filename, or '-' if standard input        ...    }
}my $*ARGFILES = IO::ArgFiles.new(filenames =&gt; @*ARGS);.say for $*ARGFILES.lines();

(Of course this is only a rough skeleton, you might need to change some
details, or add some things).


Submission
----------

Please submit your source code to the perl6-compiler@perl.org mailing
list (and put moritz@faui2k3.org on CC, because the mailing list
sometimes lack quite a bit).

Update:: there have been two submissions, and a mixture of both has been
applied.</summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>For this week's contribution to Perl 6 we ask you to implement the
<code>$*ARGFILES</code> special variable (and underlying object) for
Rakudo.</p>

<p>(<a href="http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html">Introduction
    to this series of challenges</a>)</p>

<h2>Background</h2>

<p>In Perl 5, there is a "magic" way to iterate over input: <code>while (my
$line = &lt;&gt;) { ... }</code>. This reads from standard input if no command
line arguments were provided. If there are command line arguments, they are
taken as file names, and <code>&lt;&gt;</code> iterates over the contents of
these files.</p>

<p>In Perl 6 this magic is performed with the <code>$*ARGFILES</code> special
variable. Please implement it!</p>

<p>To do that, you have to understand how file reading works in Perl 6. Once
you have a file handle, there are two ways to read lines: either by calling
<code>$handle.get</code>, which returns just one line, or by calling
<code>$handle.lines</code>, which returns a (lazy) list of all the remaining
lines.</p>

<p>You can obtain the command line arguments from <code>@*ARGS</code>, open a
file with <code>my $handle = open $filename;</code> for reading; And finally
you can use <code>lines('filename')</code> to read all lines from a file.</p>


<h2>What you can do</h2>

<p>Implement a backend class for <code>$*ARGFILES</code>. You can do that in
normal Perl 6 code, no need to change the actual compiler. Once that's done,
we will plug it into Rakudo. Your code might look like this:</p>

<pre>
<span class="synStatement">class</span> IO::ArgFiles {
    <span class="synSpecial">has</span> <span class="synIdentifier">@</span><span class="synSpecial">!</span><span class="synIdentifier">filenames</span><span class="synStatement">;</span>
    <span class="synStatement">method</span> get() { <span class="synStatement">...</span> }
    <span class="synStatement">method</span> <span class="synIdentifier">lines</span>() { <span class="synStatement">...</span> }
    <span class="synStatement">method</span> filename() {
        <span class="synComment"># return the current filename, or '-' if standard input</span>
        <span class="synStatement">...</span>
    }
}
<span class="synSpecial">my</span> <span class="synIdentifier">$</span><span class="synSpecial">*</span><span class="synIdentifier">ARGFILES</span> <span class="synStatement">=</span> IO::ArgFiles<span class="synStatement">.</span><span class="synIdentifier">new</span>(<span class="synConstant">filenames</span> <span class="synStatement">=&gt;</span> <span class="synIdentifier">@</span><span class="synSpecial">*</span><span class="synIdentifier">ARGS</span>)<span class="synStatement">;</span>
<span class="synStatement">.</span><span class="synIdentifier">say</span> <span class="synStatement">for</span> <span class="synIdentifier">$</span><span class="synSpecial">*</span><span class="synIdentifier">ARGFILES</span><span class="synStatement">.</span><span class="synIdentifier">lines</span>()<span class="synStatement">;</span>
</pre>

<p>(Of course this is only a rough skeleton, you might need to change some
details, or add some things).</p>

<h2>Submission</h2>

<p>Please submit your source code to the <a href="mailto:perl6-compiler@perl.org">perl6-compiler@perl.org</a> mailing
list (and put moritz@faui2k3.org on CC,
because the mailing list sometimes lack quite a bit).</p>

<p><strong>Update:</strong>: there have been two submissions, and a mixture of
both has been applied.</p>


</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/contribute-now-argfiles.html</id>
  </entry>
  <entry>
    <title> Travelling in time: the CP2000AN </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_cp2000an" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">My mad experiment in CPAN mirrors has grown a couple of new tentacles.
Previously it could be a perl-X.Y.Z-specific mirror, such as the
CP5.6.2AN, or an OS-specific mirror such as the cpMSWin32an. Now it can
combine the two such as in the CP5.8.8-irixAN and all of those can
optionally be combined with a date/time to only include stuff that was
already on the CPAN as at that time, such as at the CP2000AN.

Why do this? Let's assume that you have a large complex application which
uses lots of stuff from the CPAN, and depends on Elk version 1.009 and
ListOfDogs version 5.1, and will break with any later version of Elk (or
of ListOfDogs). You get a feature request from a user, and think "ah-ha,
there's a module for that", and so you go to install Some::Module.
Unfortunately, the latest version of Some::Module depends on
Some::Other::Module which in turn needs Another::Module which needs Elk
1.234, so your CPAN client merrily upgrades Elk, breaking everything.
Doom and Disaster. Having a CPAN "mirror" nailed to the date of the last
release of Elk and ListOfDogs that works for you will save you from pain,
suffering, and the Dark Side. Either you'll get older versions that Just
Work, or you'll get nothing, and nothing is far better than breaking
everything!</div>
    </summary>
    <content type="text">My mad experiment in CPAN mirrors has grown a couple of new tentacles.  Previously it could be a perl-X.Y.Z-specific mirror, such as &lt;a href="http://cp5.6.2an.barnyard.co.uk"&gt;the CP5.6.2AN&lt;/a&gt;, or an OS-specific mirror such as &lt;a href="http://cpMSWin32an.barnyard.co.uk/"&gt;the cpMSWin32an&lt;/a&gt;.  Now it can combine the two such as in &lt;a href="http://cp5.8.8-irixan.barnyard.co.uk/"&gt;the CP5.8.8-irixAN&lt;/a&gt; and all of those can optionally be combined with a date/time to only include stuff that was already on the CPAN as at that time, such as at &lt;a href="http://cp2000an.barnyard.co.uk"&gt;the CP2000AN&lt;/a&gt;.&lt;p&gt;Why do this?  Let's assume that you have a large complex application which uses lots of stuff from the CPAN, and depends on Elk version 1.009 and ListOfDogs version 5.1, and will break with any later version of Elk (or of ListOfDogs).  You get a feature request from a user, and think "ah-ha, there's a module for that", and so you go to install Some::Module.  Unfortunately, the latest version of Some::Module depends on Some::Other::Module which in turn needs Another::Module which needs Elk 1.234, so your CPAN client merrily upgrades Elk, breaking everything.  Doom and Disaster.  Having a CPAN "mirror" nailed to the date of the last release of Elk and ListOfDogs that works for you will save you from pain, suffering, and the Dark Side.  Either you'll get older versions that Just Work, or you'll get nothing, and nothing is far better than breaking everything!
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_cp2000an</id>
  </entry>
  <entry>
    <title>Common Perl 6 data processing idioms</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-5-to-6/27-common-idioms.html" type="text/html"/>
    <summary type="text">NAME

"Perl 5 to 6" Lesson 27 - Common Perl 6 data processing idioms


SYNOPSIS

  # create a hash from a list of keys and values:
  # solution 1: slices
  my %hash; %hash{@keys} = @values;
  # solution 2: meta operators
  my %hash = @keys Z=&gt; @values;

  # create a hash from an array, with
  # true value for each array item:
  my %exists = @keys Z=&gt; 1 xx *;

  # limit a value to a given range, here 0..10.
  my $x = -2;
  say 0 max $x min 10;

  # for debugging: dump the contents of a variable,
  # including its name, to STDERR
  note :$x.perl;

  # sort case-insensitively
  say @list.sort: *.lc;

  # mandatory attributes
  class Something {
      has $.required = die "Attribute 'required' is mandatory";
  }
  Something.new(required =&gt; 2); # no error
  Something.new()               # BOOM


DESCRIPTION

Learning the specification of a language is not enough to be productive
with it. Rather you need to know how to solve specific problems. Common
usage patterns, called idioms, helps you not having to re-invent the
wheel every time you're faced with a problem.

So here a some common Perl 6 idioms, dealing with data structures.

Hashes

  # create a hash from a list of keys and values:
  # solution 1: slices
  my %hash; %hash{@keys} = @values;
  # solution 2: meta operators
  my %hash = @keys Z=&gt; @values;

The first solution is the same you'd use in Perl 5: assignment to a
slice. The second solution uses the zip operator Z, which joins to list
like a zip fastener: 1, 2, 3 Z 10, 20, 30 is 1, 10, 2, 20, 3, 30. The Z=&gt;
is a meta operator, which combines zip with =&gt; (the Pair construction
operator). So 1, 2, 3 Z=&gt; 10, 20, 30 evaluates to 1 =&gt; 10, 2 =&gt; 20, 3 =&gt;
30. Assignment to a hash variable turns that into a Hash.

For existence checks, the values in a hash often doesn't matter, as long
as they all evaluate to True in boolean context. In that case, a nice way
to initialize the hash from a given array or list of keys is

  my %exists = @keys Z=&gt; 1 xx *;

which uses a lazy, infinite list of 1s on the right-hand side, and relies
on the fact that Z ends when the shorter list is exhausted.

Numbers

Sometimes you want to get a number from somewhere, but clip it into a
predefined range (for example so that it can act as an array index).

In Perl 5 you often end up with things like $a = $b &gt; $upper ? $upper :
$b, and another conditional for the lower limit. With the max and min
infix operators, that simplifies considerably to

  my $in-range = $lower max $x min $upper;

because $lower max $x returns the larger of the two numbers, and thus
clipping to the lower end of the range.

Since min and max are infix operators, you can also clip infix:

 $x max= 0;
 $x min= 10;

Debugging

Perl 5 has Data::Dumper, Perl 6 objects have the .perl method. Both
generate code that reproduces the original data structure as faithfully
as possible.

:$var generates a Pair ("colonpair"), using the variable name as key (but
with sigil stripped). So it's the same as var =&gt; $var. note() writes to
the standard error stream, appending a newline. So note :$var.perl is
quick way of obtaining the value of a variable for debugging; purposes,
along with its name.

Sorting

Like in Perl 5, the sort built-in can take a function that compares two
values, and then sorts according to that comparison. Unlike Perl 5, it's
a bit smarter, and automatically does a transformation for you if the
function takes only one argument.

In general, if you want to compare by a transformed value, in Perl 5 you
can do:

    # WARNING: Perl 5 code ahead
    my @sorted = sort { transform($a) cmp transform($b) } @values;

    # or the so-called Schwartzian Transform:
    my @sorted = map { $_-&gt;[1] }
                 sort { $a-&gt;[0] cmp $b-&gt;[0] }
                 map { [transform($_), $_] }
                 @values

The former solution requires repetitive typing of the transformation, and
executes it for each comparison. The second solution avoids that by
storing the transformed value along with the original value, but it's
quite a bit of code to write.

Perl 6 automates the second solution (and a bit more efficient than the
naiive Schwartzian transform, by avoiding an array for each value) when
the transformation function has arity one, ie accepts one argument only:

    my @sorted = sort &amp;transform, @values;

Mandatory Attributes

The typical way to enforce the presence of an attribute is to check its
presence in the constructor - or in all constructors, if there are many.

That works in Perl 6 too, but it's easier and safer to require the
presence at the level of each attribute:

    has $.attr = die "'attr' is mandatory";

This exploits the default value mechanism. When a value is supplied, the
code for generating the default value is never executed, and the die
never triggers. If any constructor fails to set it, an exception is
thrown.


MOTIVATION

N/A</summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<h3><a class="u" href="#___top" title="click to go to top of document" name="NAME">NAME</a></h3>

<p>"Perl 5 to 6" Lesson 27 - Common Perl 6 data processing idioms</p>

<h3><a class="u" href="#___top" title="click to go to top of document" name="SYNOPSIS">SYNOPSIS</a></h3>

<pre>  # create a hash from a list of keys and values:
  # solution 1: slices
  my %hash; %hash{@keys} = @values;
  # solution 2: meta operators
  my %hash = @keys Z=&gt; @values;

  # create a hash from an array, with
  # true value for each array item:
  my %exists = @keys Z=&gt; 1 xx *;

  # limit a value to a given range, here 0..10.
  my $x = -2;
  say 0 max $x min 10;

  # for debugging: dump the contents of a variable,
  # including its name, to STDERR
  note :$x.perl;

  # sort case-insensitively
  say @list.sort: *.lc;

  # mandatory attributes
  class Something {
      has $.required = die "Attribute 'required' is mandatory";
  }
  Something.new(required =&gt; 2); # no error
  Something.new()               # BOOM</pre>

<h3><a class="u" href="#___top" title="click to go to top of document" name="DESCRIPTION">DESCRIPTION</a></h3>

<p>Learning the specification of a language is not enough to be productive with it. Rather you need to know how to solve specific problems. Common usage patterns, called <i>idioms</i>, helps you not having to re-invent the wheel every time you're faced with a problem.</p>

<p>So here a some common Perl 6 idioms, dealing with data structures.</p>

<h4><a class="u" href="#___top" title="click to go to top of document" name="Hashes">Hashes</a></h4>

<pre>  # create a hash from a list of keys and values:
  # solution 1: slices
  my %hash; %hash{@keys} = @values;
  # solution 2: meta operators
  my %hash = @keys Z=&gt; @values;</pre>

<p>The first solution is the same you'd use in Perl 5: assignment to a slice. The second solution uses the zip operator <code>Z</code>, which joins to list like a zip fastener: <code>1, 2, 3 Z 10, 20, 30</code> is <code>1, 10, 2, 20, 3, 30</code>. The <code>Z=&gt;</code> is a meta operator, which combines zip with <code>=&gt;</code> (the Pair construction operator). So <code>1, 2, 3 Z=&gt; 10, 20, 30</code> evaluates to <code>1 =&gt; 10, 2 =&gt; 20, 3 =&gt; 30</code>. Assignment to a hash variable turns that into a Hash.</p>

<p>For existence checks, the values in a hash often doesn't matter, as long as they all evaluate to <code>True</code> in boolean context. In that case, a nice way to initialize the hash from a given array or list of keys is</p>

<pre>  my %exists = @keys Z=&gt; 1 xx *;</pre>

<p>which uses a lazy, infinite list of 1s on the right-hand side, and relies on the fact that <code>Z</code> ends when the shorter list is exhausted.</p>

<h4><a class="u" href="#___top" title="click to go to top of document" name="Numbers">Numbers</a></h4>

<p>Sometimes you want to get a number from somewhere, but clip it into a predefined range (for example so that it can act as an array index).</p>

<p>In Perl 5 you often end up with things like <code>$a = $b &gt; $upper ? $upper : $b</code>, and another conditional for the lower limit. With the <code>max</code> and <code>min</code> infix operators, that simplifies considerably to</p>

<pre>  my $in-range = $lower max $x min $upper;</pre>

<p>because <code>$lower max $x</code> returns the larger of the two numbers, and thus clipping to the lower end of the range.</p>

<p>Since <code>min</code> and <code>max</code> are infix operators, you can also clip infix:</p>

<pre> $x max= 0;
 $x min= 10;</pre>

<h4><a class="u" href="#___top" title="click to go to top of document" name="Debugging">Debugging</a></h4>

<p>Perl 5 has Data::Dumper, Perl 6 objects have the <code>.perl</code> method. Both generate code that reproduces the original data structure as faithfully as possible.</p>

<p><code>:$var</code> generates a Pair ("colonpair"), using the variable name as key (but with sigil stripped). So it's the same as <code>var =&gt; $var</code>. <code>note()</code> writes to the standard error stream, appending a newline. So <code>note :$var.perl</code> is quick way of obtaining the value of a variable for debugging; purposes, along with its name.</p>

<h4><a class="u" href="#___top" title="click to go to top of document" name="Sorting">Sorting</a></h4>

<p>Like in Perl 5, the <code>sort</code> built-in can take a function that compares two values, and then sorts according to that comparison. Unlike Perl 5, it's a bit smarter, and automatically does a transformation for you if the function takes only one argument.</p>

<p>In general, if you want to compare by a transformed value, in Perl 5 you can do:</p>

<pre>    # WARNING: Perl 5 code ahead
    my @sorted = sort { transform($a) cmp transform($b) } @values;

    # or the so-called Schwartzian Transform:
    my @sorted = map { $_-&gt;[1] }
                 sort { $a-&gt;[0] cmp $b-&gt;[0] }
                 map { [transform($_), $_] }
                 @values</pre>

<p>The former solution requires repetitive typing of the transformation, and executes it for each comparison. The second solution avoids that by storing the transformed value along with the original value, but it's quite a bit of code to write.</p>

<p>Perl 6 automates the second solution (and a bit more efficient than the naiive Schwartzian transform, by avoiding an array for each value) when the transformation function has arity one, ie accepts one argument only:</p>

<pre>    my @sorted = sort &amp;transform, @values;</pre>

<h4><a class="u" href="#___top" title="click to go to top of document" name="Mandatory_Attributes">Mandatory Attributes</a></h4>

<p>The typical way to enforce the presence of an attribute is to check its presence in the constructor - or in all constructors, if there are many.</p>

<p>That works in Perl 6 too, but it's easier and safer to require the presence at the level of each attribute:</p>

<pre>    has $.attr = die "'attr' is mandatory";</pre>

<p>This exploits the default value mechanism. When a value is supplied, the code for generating the default value is never executed, and the <code>die</code> never triggers. If any constructor fails to set it, an exception is thrown.</p>

<h3><a class="u" href="#___top" title="click to go to top of document" name="MOTIVATION">MOTIVATION</a></h3>

<p>N/A</p>

 </div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-5-to-6/27-common-idioms.html</id>
  </entry>
  <entry>
    <title> Thankyou, Anonymous Benefactor! </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_thankyou-anonymous-benefactor" type="text/html"/>
    <summary type="text">I got home this evening to find an Unexpected Parcel waiting for me, full of books. I have no idea who it's from, but I'm guessing that it's from someone who finds &lt;a href=http://deps.cpantesters.org/&gt;CPANdeps&lt;/a&gt; useful. Thank you, Anonymous Benefactor! Your generosity is much appreciated!
</summary>
    <content type="text">I got home this evening to find an Unexpected Parcel waiting for me, full of books. I have no idea who it's from, but I'm guessing that it's from someone who finds &lt;a href=http://deps.cpantesters.org/&gt;CPANdeps&lt;/a&gt; useful. Thank you, Anonymous Benefactor! Your generosity is much appreciated!
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_thankyou-anonymous-benefactor</id>
  </entry>
  <entry>
    <title> cgit syntax highlighting </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_cgit-syntax-highlighting" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">For the last few months I've been using git for my version control
system. It's better than CVS because it can handle offline commits. So if
I'm using my laptop on a train, I can still use version control without
having to have a notwork connection.

And to give a pretty web front-end to it for other people to read code
without having to check it out of the repository, I use cgit, which I
mostly chose because it's a dead simple CGI and not a huge fancy
application.

One problem with cgit is that by default it doesn't do code highlighting.
But it has the ability to run blobs of code through any filter you care
to name before displaying them, so to get something nice like this all
you need to do is write a highlighter and add a single line to your
cgitrc:

source-filter=/web/www.cantrell.org.uk/cgit/highlighter

My highlighter program is this:

   1 #!/usr/local/bin/perl
   2 
   3 use warnings;
   4 use strict;
   5 
   6 my $file = shift;
   7 
   8 if($file =~ /\.(p[ml]|t)$/i) {
   9     system "/usr/local/bin/perltidy -html -st -ntoc -npod -pre -nss -nnn"  10 } else {
  11     system "cat -n";
  12 }</div>
    </summary>
    <content type="text">For the last few months I've been using &lt;a href="http://git-scm.com/"&gt;git&lt;/a&gt; for my version control system.  It's better than CVS because it can handle offline commits.  So if I'm using my laptop on a train, I can still use version control without having to have a notwork connection.&lt;p&gt;And to give a pretty web front-end to it for other people to &lt;a href="http://www.cantrell.org.uk/cgit/"&gt;read code&lt;/a&gt; without having to check it out of the repository, I use &lt;a href="http://hjemli.net/git/cgit/"&gt;cgit&lt;/a&gt;, which I mostly chose because it's a dead simple CGI and not a huge fancy application.&lt;p&gt;One problem with cgit is that by default it doesn't do code highlighting.  But it has the ability to run blobs of code through any filter you care to name before displaying them, so to get something nice like &lt;a href="http://www.cantrell.org.uk/cgit/cgit.cgi/perlmodules/tree/Sub-WrapPackages/lib/Sub/WrapPackages.pm?id=db12893c451365b8f546b9f253735be1c542b6c0"&gt;this&lt;/a&gt; all you need to do is write a highlighter and add a single line to your cgitrc:&lt;p&gt;&lt;code&gt;source-filter=/web/www.cantrell.org.uk/cgit/highlighter&lt;/code&gt;&lt;p&gt;My highlighter program is this:&lt;p&gt;&lt;pre&gt;
   1 #!/usr/local/bin/perl
   2 
   3 &lt;b&gt;&lt;font color="#8B008B"&gt;use&lt;/font&gt;&lt;/b&gt; warnings;
   4 &lt;b&gt;&lt;font color="#8B008B"&gt;use&lt;/font&gt;&lt;/b&gt; strict;
   5 
   6 &lt;b&gt;&lt;font color="#8B008B"&gt;my&lt;/font&gt;&lt;/b&gt; &lt;font color="#00688B"&gt;$file&lt;/font&gt; = &lt;b&gt;&lt;font color="#8B008B"&gt;shift&lt;/font&gt;&lt;/b&gt;;
   7 
   8 &lt;b&gt;&lt;font color="#8B008B"&gt;if&lt;/font&gt;&lt;/b&gt;(&lt;font color="#00688B"&gt;$file&lt;/font&gt; =~ &lt;font color="#CD5555"&gt;/\.(p[ml]|t)$/i&lt;/font&gt;) {
   9     &lt;b&gt;&lt;font color="#8B008B"&gt;system&lt;/font&gt;&lt;/b&gt; &lt;font color="#CD5555"&gt;&amp;quot;/usr/local/bin/perltidy -html -st -ntoc -npod -pre -nss -nnn&amp;quot;&lt;/font&gt;
  10 } &lt;b&gt;&lt;font color="#8B008B"&gt;else&lt;/font&gt;&lt;/b&gt; {
  11     &lt;b&gt;&lt;font color="#8B008B"&gt;system&lt;/font&gt;&lt;/b&gt; &lt;font color="#CD5555"&gt;&amp;quot;cat -n&amp;quot;&lt;/font&gt;;
  12 }
&lt;/pre&gt;&lt;p&gt;</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_cgit-syntax-highlighting</id>
  </entry>
  <entry>
    <title>Gabor: Keep going</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/gabor-keep-going.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">After reading this blog post, I just want to say: keep going.

Gabor does really awesome things for Perl (and especially for Perl 6,
which I tend to notice more): beginner's tutorials, screencasts, training
courses, writes an IDE and so on. If his primary interest was his own
success, his priorities would be quite different.

I hope that Gabor doesn't pay too much attention to the hostilities from
parts of the Perl community, and I wish him and us all the best for his
current project.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>After reading <a href="http://blogs.perl.org/users/gabor_szabo/2010/07/promoting-perl-is-fun.html">this
blog post</a>, I just want to say: keep going.</p>

<p>Gabor does really awesome things for Perl (and especially for Perl 6, which
I tend to notice more): beginner's tutorials, screencasts, training courses,
writes an IDE and so on. If his primary interest was his own success, his
priorities would be quite different.</p>

<p>I hope that Gabor doesn't pay too much attention to the hostilities from
parts of the Perl community, and I wish him and us all the best for his <a href="http://news.perlfoundation.org/2010/06/hague-grant-application-perl-e.html">current
project</a>.</p>


</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/gabor-keep-going.html</id>
  </entry>
  <entry>
    <title> Graphing tool </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_graphing-tool" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">[IMAGE][IMAGE]I made a shiny thing! It can plot arbitrary functions of
the form x=f(y) or y=f(x). Under the skin, it just massages its arguments
and passes them through to Gnuplot. Here's the source code.

Update: now 48.3% even shinier - see on the right</div>
    </summary>
    <content type="html">&lt;a href="/david/chart.pl?plot=y=(x/2)^2|x=y^3+3sin(y^2)-5y+4"&gt;&lt;img&gt;&lt;/a&gt;&lt;a href="/david/chart.pl?plot=x=sin(6t^2)+2t-2,y=2sin(t^2)-4t"&gt;&lt;img&gt;&lt;/a&gt;I made a shiny thing!  It can plot arbitrary functions of the form x=f(y) or y=f(x).  Under the skin, it just massages its arguments and passes them through to &lt;a href="http://gnuplot.info/"&gt;Gnuplot&lt;/a&gt;.  &lt;a href="/david/chart.src.txt"&gt;Here&lt;/a&gt;'s the source code.&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; now 48.3% even shinier - see on the right
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_graphing-tool</id>
  </entry>
  <entry>
    <title> Ill </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_ill" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I am ill. I've been ill since Thursday, with a cold. You're meant to be
able to cure a cold with [insert old wives tale remedy here] in 5 days,
or if you don't, it'll clear itself up in just under a week. So hopefully
today is the last day.

So what have I done while ill?

On Friday I became old (see previous post), and went to the Byzantium
exhibition at the Royal Academy. It was good. You should go.

Saturday was the London Perl Workshop. My talk on closures went down
well, and people seemed to understand what I was talking about. Hurrah! I
decided that rather than hang around nattering and going to a few talks,
I'd rather hide under my duvet for the rest of the day.

I mostly hid on Sunday too, and spent most of the day asleep. In a brief
moment of productivity, I got my laptop and my phone to talk to each
other using magic interwebnet bluetooth stuff. I'd tried previously
without success, but that was with the previous release of OS X. With
version X.5 it seems to Just Work, so no Evil Hacks were necessary.

The cold means that I can't taste a damned thing, not even bacon. So now
I know what it's like to be Jewish. Being Jewish sucks.

And today, I am still coughing up occasional lumps of lung and making odd
bubbling noises in my chest, although my nasal demons seem to be Snotting
less than they were, so hopefully I'll be back to normal tomorrow.</div>
    </summary>
    <content type="text">I am ill.  I've been ill since Thursday, with a cold.  You're meant to be able to cure a cold with [insert old wives tale remedy here] in 5 days, or if you don't, it'll clear itself up in just under a week.  So hopefully today is the last day.&lt;p&gt;So what have I done while ill?&lt;p&gt;On Friday I became old (see previous post), and went to the &lt;a href="http://www.royalacademy.org.uk/exhibitions/byzantium/"&gt;Byzantium&lt;/a&gt; exhibition at the Royal Academy.  It was good.  You should go.&lt;p&gt;Saturday was the &lt;a href="http://conferences.yapceurope.org/lpw2008/"&gt;London Perl Workshop&lt;/a&gt;.  My talk on closures went down well, and people seemed to understand what I was talking about.  Hurrah!  I decided that rather than hang around nattering and going to a few talks, I'd rather hide under my duvet for the rest of the day.&lt;p&gt;I mostly hid on Sunday too, and spent most of the day asleep.  In a brief moment of productivity, I got my laptop and my phone to talk to each other using magic interwebnet bluetooth stuff.  I'd tried previously without success, but that was with the previous release of OS X.  With version X.5 it seems to Just Work, so no Evil Hacks were necessary.&lt;p&gt;The cold means that I can't taste a damned thing, not even bacon.  So now I know what it's like to be Jewish.  Being Jewish &lt;em&gt;sucks&lt;/em&gt;.&lt;p&gt;And today, I am still coughing up occasional lumps of lung and making odd bubbling noises in my chest, although my nasal demons seem to be Snotting less than they were, so hopefully I'll be back to normal tomorrow.  
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_ill</id>
  </entry>
  <entry>
    <title> Devel::CheckLib can now check libraries' contents </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_Devel-CheckLib-functions" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Devel::CheckLib has grown a new feature. As well as checking that
libraries and headers exist, it can now also check that particular
functions exist in a library and check their return values. This will be
particularly useful if you need to check that a particular version of a
library is available.

It works if you have a Unixish toolchain. I need to wait for the
CPAN-testers reports to see if I managed not to break anything on
Windows. Unfortunately, even though the lovely Mr. Alias has worked hard
to make Windows machines available to developers, I found it to be just
too hard to use. Even downloading my code to the Windows machine was
hard, as Windows seemed to think it knew better and shouldn't download
the file I told it to download. Then once I had downloaded it, Windows
decided to hide it somewhere that I couldn't get to using the command
line. So I gave up.

I might try again once there are some decent tools on the machines: wget,
tar, and gzip at minimum, as given those I can quickly bootstrap anything
else. Software development isn't just about having compilers available.</div>
    </summary>
    <content type="html">&lt;a href="http://search.cpan.org/search?query=Devel%3A%3ACheckLib&amp;amp;mode=all"&gt;Devel::CheckLib&lt;/a&gt; has grown a new feature.  As well as checking that libraries and headers exist, it can now also check that particular functions exist in a library and check their return values.  This will be particularly useful if you need to check that a particular &lt;em&gt;version&lt;/em&gt; of a library is available.&lt;p&gt;It works if you have a Unixish toolchain.  I need to wait for the CPAN-testers reports to see if I managed not to break anything on Windows.  Unfortunately, even though the lovely Mr. Alias has worked hard to make &lt;a href="http://use.perl.org/~Alias/journal/39318"&gt;Windows machines available to developers&lt;/a&gt;, I found it to be just too hard to use.  Even downloading my code to the Windows machine was hard, as Windows seemed to think it knew better and shouldn't download the file I told it to download.  Then once I had downloaded it, Windows decided to hide it somewhere that I couldn't get to using the command line.  So I gave up.&lt;p&gt;I might try again once there are some decent tools on the machines: wget, tar, and gzip at minimum, as given those I can quickly bootstrap anything else.  Software development isn't just about having compilers available.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_Devel-CheckLib-functions</id>
  </entry>
  <entry>
    <title>Want to write shiny SVG graphics with Perl 6? Port Scruffy!</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/want-to-write-shiny-graphics.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">First let my apologize for waiting so long to come up with a new "weekly"
Perl 6 challenge - I'm running out of ideas, and the one I have left
needs more time to prepare.

Instead I want to motivate you to help porting the ruby scruffy charting
library to Perl 6. It can generate shiny SVG graphics (they are currently
broken on their main website, hence the waybackmachine link).

There's already an initial version Perl 6 port called "tufte", but it's
not running yet. It needs your help. If you know a little ruby, and want
to learn some more Perl 6, join #perl6, ask for a commit bit, and
translate some ruby code into Perl 6. And in the end you'll be rewarded
with nice SVG charts :-).</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>First let my apologize for waiting so long to come up with a new 
<a href="http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html">"weekly"
    Perl 6 challenge</a> - I'm running out of ideas, and the one I have left needs
more time to prepare.</p>

<p>Instead I want to motivate you to help porting the ruby <a href="http://scruffy.rubyforge.org/">scruffy charting library</a> to Perl 6.
It can generate <a href="http://replay.waybackmachine.org/20080625015853/http://scruffy.rubyforge.org/">shiny
SVG graphics</a> (they are currently broken on their main website, hence the
waybackmachine link).</p>


<p>There's already an <a href="http://github.com/moritz/tufte/">initial
version Perl 6 port called "tufte"</a>, but it's not running yet. It needs your
help. If you know a little ruby, and want to learn some more Perl 6, join
#perl6, ask for a commit bit, and translate some ruby code into Perl 6. And in
the end you'll be rewarded with nice SVG charts :-).</p>


</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/want-to-write-shiny-graphics.html</id>
  </entry>
  <entry>
    <title> POD includes </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_pod-includes" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">One of my CPAN distributions is CPAN-FindDependencies. It contains a
module CPAN::FindDependencies, and a simple script that wraps around it
so you can view dependencies easily from the command line. That script,
naturally, has a man page. However, that manpage basically says "if you
want to know what arguments this program takes, see the
CPAN::FindDependencies docs". This is Bad from a usability point of view,
good from a not-duplicating-stuff point of view, and good from a laziness
point of view. Which means that it's Bad.

So, the solution.

  =over

  #include shared/parameters

  =back

and some Magic that does the cpp-stylee substitution at make dist time.
Note the 'dist' section in my call to WriteMakefile.

This is, of course, crying out to be made less horribly hacky, but it
works for now, so I'm happy.

My original idea was to write some crazy shit that would do the #include
at install-time, when the user was installing my code. But that has the
disadvantage that tools like search.cpan wouldn't show it properly, as
they simply look at the files in the distribution. So this does the
#includes at the last moment just before I package up the code and upload
to the PAUSE. You lovely people get the right documentation in all the
right places, I only have to maintain it in one place so it stays in
sync, and (in the interests of Laziness) I don't have to remember to run
any extra scripts before releasing, make dist just Does The Right Thing.</div>
    </summary>
    <content type="text">One of my CPAN distributions is &lt;a href="http://search.cpan.org/search?query=CPAN-FindDependencies"&gt;CPAN-FindDependencies&lt;/a&gt;.  It contains a module CPAN::FindDependencies, and a simple script that wraps around it so you can view dependencies easily from the command line.  That script, naturally, has a man page.  However, that manpage basically says "if you want to know what arguments this program takes, see the CPAN::FindDependencies docs".  This is Bad from a usability point of view, good from a not-duplicating-stuff point of view, and good from a laziness point of view.  Which means that it's Bad.&lt;p&gt;So, the solution.&lt;p&gt;&lt;blockquote&gt;&lt;tt&gt;
=over&lt;p&gt;#include shared/parameters&lt;p&gt;=back
&lt;/tt&gt;&lt;/blockquote&gt;&lt;p&gt;and some &lt;a href="http://www.cantrell.org.uk/cgit/cgit.cgi/perlmodules/tree/CPAN-FindDependencies/Makefile.PL?id=b643a4d95f300552b9af9e7edd1fef9ae96543b3"&gt;Magic&lt;/a&gt; that does the &lt;a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.3/cpp/"&gt;cpp-stylee&lt;/a&gt; substitution at &lt;code&gt;make dist&lt;/code&gt; time.  Note the 'dist' section in my call to &lt;code&gt;WriteMakefile&lt;/code&gt;.&lt;p&gt;This is, of course, crying out to be made less horribly hacky, but it works for now, so I'm happy.&lt;p&gt;My original idea was to write some crazy shit that would do the #include at install-time, when the user was installing my code.  But that has the disadvantage that tools like &lt;a href="http://search.cpan.org/"&gt;search.cpan&lt;/a&gt; wouldn't show it properly, as they simply look at the files in the distribution.  So this does the #includes at the last moment just before I package up the code and upload to the PAUSE.  You lovely people get the right documentation in all the right places, I only have to maintain it in one place so it stays in sync, and (in the interests of Laziness) I don't have to remember to run any extra scripts before releasing, &lt;code&gt;make dist&lt;/code&gt; just Does The Right Thing.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_pod-includes</id>
  </entry>
  <entry>
    <title>Perl 6 Questions on Perlmonks</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/perlmonks-questions.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Since the Rakudo Star release, there has been a noticeable increase in
Perl 6 questions on perlmonks - a good sign, because it means people are
using it.

  * Array interpolation in Rakudo

  * Rakudo build problems

  * Perl6, latest Rakudo bug or error on my part? (parsing issue related
    to missing whitespace).

  * Perl6, modifying @*INC (another ws parsing issue)

  * Perl6's LWP::Simple -- seemingly an installation issue

  * Perl 6, defining a hash with interpolated string

I've assembled this list by looking through the 100 newest nodes in
Seekers of Perl Wisdom, which makes it 6% of the questions asked, or on
average 1 per day (used to be around 1 per week).

Most of the questions are related to environmental issues
(building/installing stuff), or beginner's questions related to syntax.

It's good to see the questions flowing in, and I hope that we'll soon see
more questions where I can show off cool Perl 6 features in the answers
:-).</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
<p>Since the Rakudo Star release, there has been a noticeable increase in Perl
6 questions on perlmonks - a good sign, because it means people are using
it.</p>

<ul>
    <li><a href="http://www.perlmonks.org/?node_id=853975">Array interpolation
        in Rakudo</a></li>
    <li><a href="http://www.perlmonks.org/?node_id=853727">Rakudo build
        problems</a></li>
    <li><a href="http://www.perlmonks.org/?node_id=853573">Perl6, latest
        Rakudo bug or error on my part?</a> (parsing issue related to missing
        whitespace).</li>
    <li><a href="http://www.perlmonks.org/?node_id=853149">Perl6, modifying
        @*INC</a> (another ws parsing issue)</li>
    <li><a href="http://www.perlmonks.org/?node_id=853113">Perl6's
        LWP::Simple</a> -- seemingly an installation issue</li>
    <li><a href="http://www.perlmonks.org/?node_id=852900">Perl 6, defining a
        hash with interpolated string</a></li>
</ul>

<p>I've assembled this list by looking through the 100 newest nodes in <a href="http://www.perlmonks.org/?node=Seekers%20of%20Perl%20Wisdom">Seekers of
Perl Wisdom</a>, which makes it 6% of the questions asked, or on average 1 per
day (used to be around 1 per week).</p>

<p>Most of the questions are related to environmental issues
(building/installing stuff), or beginner's questions related to syntax.</p>

<p>It's good to see the questions flowing in, and I hope that we'll soon see
more questions where I can show off cool Perl 6 features in the answers
:-).</p>


</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/perlmonks-questions.html</id>
  </entry>
  <entry>
    <title> YAPC::Europe 2007 report: day 1 </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2007-day-1" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">As is becoming normal, I used the times between talks to bugfix some of
my modules - this time Tie::STDOUT and Data::Transactional. The former
was failing on perl 5.6, the latter on 5.9.5. The former was a bug in
perl (you can't localise tied filehandles and expect the tieing to go
away in 5.6, so it now declares a dependency on 5.8), the latter was a
bug in my code.

Philippe Bruhat's talk on Net::Proxy was great - you can tell it's great
because I came away with ideas for at least four things that I need to
write. First up will be a plugin for it to allow the user to specify
minimum and maximum permitted data rates for proxied connections. This
will permit bandwidth limits for maximum permitted rates, but will also
help to defeat IDSes doing traffic analysis if you specify a minimum
permitted data rate.

This will protect (eg) ssh sessions from being identified based on their
very bursty traffic pattern, by "filling in the blanks" with junk data.

In the evening, the CPAN-testers BOF was productive.</div>
    </summary>
    <content type="text">As is becoming normal, I used the times between talks to bugfix some of my modules - this time &lt;a href="http://search.cpan.org/~dcantrell/Tie-STDOUT-1.03/"&gt;Tie::STDOUT&lt;/a&gt; and &lt;a href="http://search.cpan.org/~dcantrell/Data-Transactional-1.0/"&gt;Data::Transactional&lt;/a&gt;.  The former was failing on perl 5.6, the latter on 5.9.5.  The former was a bug in perl (you can't localise tied filehandles and expect the tieing to go away in 5.6, so it now declares a dependency on 5.8), the latter was a bug in my code.&lt;p&gt;Philippe Bruhat's talk on &lt;a href="http://search.cpan.org/~book/Net-Proxy-0.08/"&gt;Net::Proxy&lt;/a&gt; was great - you can tell it's great because I came away with ideas for at least four things that I &lt;em&gt;need&lt;/em&gt; to write.  First up will be a plugin for it to allow the user to specify minimum and maximum permitted data rates for proxied connections.  This will permit bandwidth limits for maximum permitted rates, but will also help to defeat IDSes doing traffic analysis if you specify a minimum permitted data rate.&lt;p&gt;This will protect (eg) ssh sessions from being identified based on their very bursty traffic pattern, by "filling in the blanks" with junk data.&lt;p&gt;In the evening, the CPAN-testers BOF was productive.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2007-day-1</id>
  </entry>
  <entry>
    <title> XML::Tiny released </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_xml-tiny" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I have released my XML::Tiny module. The parser at its core is less than
twenty lines of code. Pretty easy to follow code too, I think, and that
also includes error handling. One of my aims in writing it was to keep
memory usage and code to the absolute minimum, so it doesn't handle all
of XML. The documentation says that it supports "a useful subset of XML".
Personally, I think it supports the useful subset. It's certainly enough
to parse the data I get back from Amazon when I use their web services,
and to parse an RSS feed.</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I have released my <a href="http://www.cantrell.org.uk/david/tech/perl-modules/XML-Tiny-1.0.tar.gz">XML::Tiny</a> module.  The parser at its core is less than twenty lines of code.  Pretty easy to follow code too, I think, and that also includes error handling.  One of my aims in writing it was to keep memory usage and code to the absolute minimum, so it doesn't handle all of XML.  The documentation says that it supports "a useful subset of XML".  Personally, I think it supports <em>the</em> useful subset.  It's certainly enough to parse the data I get back from Amazon when I use their web services, and to parse an RSS feed.
</div>
    </content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_xml-tiny</id>
  </entry>
  <entry>
    <title> Palm Treo call db module </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_palm-treophonecalldb-first-release" type="text/html"/>
    <summary type="text">To make up for a disappointing gap in Palm's software for the Treo smartphone, I wrote a &lt;a href=http://www.cantrell.org.uk/david/tech/treo/call-dumper/&gt;small perl script&lt;/a&gt; to parse the database that stores my call history.  I then re-wrote it as &lt;a href=http://search.cpan.org/search?query=Palm%3A%3ATreoPhoneCallDB&gt;a re-useable module&lt;/a&gt; which also figgers out whether the call was incoming or outgoing.
</summary>
    <content type="text">To make up for a disappointing gap in Palm's software for the Treo smartphone, I wrote a &lt;a href=http://www.cantrell.org.uk/david/tech/treo/call-dumper/&gt;small perl script&lt;/a&gt; to parse the database that stores my call history.  I then re-wrote it as &lt;a href=http://search.cpan.org/search?query=Palm%3A%3ATreoPhoneCallDB&gt;a re-useable module&lt;/a&gt; which also figgers out whether the call was incoming or outgoing.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_palm-treophonecalldb-first-release</id>
  </entry>
  <entry>
    <title>This Week's Contribution to Perl 6 Week 9: Implement Hash.pick for Rakudo</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/contribute-now-hash-pick.html" type="text/html"/>
    <summary type="text">For this week's contribution to Perl 6 we ask you to implement the
Hash.pick method (which does a weighted random selection) for Rakudo.

(Introduction to this series of challenges)


Background
----------

In Perl 6 the List class has a method called pick, which randomly selects
one item from a list. It has a few more options too:

&lt;a b c&gt;.pick;       # pick one random element&lt;a b c&gt;.pick(2);    # pick two distinct, random elements&lt;a b c&gt;.pick(2, :replace); # pick two random elements, it's ok                           # if they are the same&lt;a b c&gt;.pick(*);    # return a random permutation of the elements&lt;a b c&gt;.pick(*, :replace); # infinite, random stream of elements

This is already implemented through several multi methods in Rakudo.

Now the specification describes such a method for hashes too (actually it
talks about Bags, but Rakudo doesn't have Bags yet. Pretend it says
"Hash" instead). It assumes that each value in the hash is numeric, and
that the value is a weight that determines the probability of picking one
value. For example

{a =&gt; 1, b =&gt; 2}.pick;  # returns 'a' with probability 1/3                        # and 'b' with probability 2/3
{a =&gt; 1, b =&gt; 2}.pick(*);  # &lt;a b b&gt; with probability 1/3                           # &lt;b a b&gt; with probability 1/3                           # &lt;b b a&gt; with probability 1/3{a =&gt; 1, b =&gt; 0.5}.pick(*) # dies, because the weights aren't all integers{a =&gt; 1, b =&gt; 0.5}.pick(*, :replace)  # ok 


What you can do
---------------

Implement Hash.pick. It's ok if your patch doesn't cover all cases. It
would be nice if it supported non-integer weights.

Hint: this could be done by storing a list of accumulated weights, and a
list of keys.

{a =&gt; 1, b =&gt; 2.5, c =&gt; 1}
# could translate to my @keys = ('a', 'b', 'c');my @accumulated_weights = (1, 3.5, 4.5);# now pick a random number between 0 and 4.5,# find the next-highest index in @accumulated_weights# with a binary search, and then use that to obtain the key.

Of course other schemes are fine too.

Second hint: because it takes quite some time to recompile Rakudo, it is
probably easier to implement the actual logic in a function in a normal
source file first, and only later move it into src/core/Hash.pm.


Submission
----------

Please submit your source code to the perl6-compiler@perl.org mailing
list (and put moritz@faui2k3.org on CC, because the mailing list
sometimes lack quite a bit).

Update: there's one submission on the perl6-compiler mailing list
already, which looks pretty good.</summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>For this week's contribution to Perl 6 we ask you to implement the
<code>Hash.pick</code> method (which does a weighted random selection) for
Rakudo.</p>

<p>(<a href="http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html">Introduction
    to this series of challenges</a>)</p>

<h2>Background</h2>

<p>In Perl 6 the <code>List</code> class has a method called <code>pick</code>,
which randomly selects one item from a list. It has a few more options
too:</p>

<pre>
<span class="synSpecial">&lt;</span><span class="synConstant">a b c</span><span class="synSpecial">&gt;</span><span class="synStatement">.</span><span class="synIdentifier">pick</span><span class="synStatement">;</span>       <span class="synComment"># pick one random element</span>
<span class="synSpecial">&lt;</span><span class="synConstant">a b c</span><span class="synSpecial">&gt;</span><span class="synStatement">.</span><span class="synIdentifier">pick</span>(<span class="synConstant">2</span>)<span class="synStatement">;</span>    <span class="synComment"># pick two distinct, random elements</span>
<span class="synSpecial">&lt;</span><span class="synConstant">a b c</span><span class="synSpecial">&gt;</span><span class="synStatement">.</span><span class="synIdentifier">pick</span>(<span class="synConstant">2</span><span class="synStatement">,</span> <span class="synStatement">:</span><span class="synConstant">replace</span>)<span class="synStatement">;</span> <span class="synComment"># pick two random elements, it's ok</span>
                           <span class="synComment"># if they are the same</span>
<span class="synSpecial">&lt;</span><span class="synConstant">a b c</span><span class="synSpecial">&gt;</span><span class="synStatement">.</span><span class="synIdentifier">pick</span>(<span class="synStatement">*</span>)<span class="synStatement">;</span>    <span class="synComment"># return a random permutation of the elements</span>
<span class="synSpecial">&lt;</span><span class="synConstant">a b c</span><span class="synSpecial">&gt;</span><span class="synStatement">.</span><span class="synIdentifier">pick</span>(<span class="synStatement">*,</span> <span class="synStatement">:</span><span class="synConstant">replace</span>)<span class="synStatement">;</span> <span class="synComment"># infinite, random stream of elements</span>
</pre>

<p>This is already <a href="http://github.com/rakudo/rakudo/blob/master/src/core/Any-list.pm#L165">implemented
through several multi methods in Rakudo</a>.</p>

<p>Now the specification <a href="http://perlcabal.org/syn/S32/Containers.html#Bag">describes such a
method for hashes too</a> (actually it talks about Bags, but Rakudo doesn't
have Bags yet. Pretend it says "Hash" instead). It assumes that each value in
the hash is numeric, and that the value is a weight that determines the
probability of picking one value. For example</p>

<pre>
{<span class="synConstant">a</span> <span class="synStatement">=&gt;</span> <span class="synConstant">1</span><span class="synStatement">,</span> <span class="synConstant">b</span> <span class="synStatement">=&gt;</span> <span class="synConstant">2</span>}<span class="synStatement">.</span><span class="synIdentifier">pick</span><span class="synStatement">;</span>  <span class="synComment"># returns 'a' with probability 1/3</span>
                        <span class="synComment"># and 'b' with probability 2/3</span>

{<span class="synConstant">a</span> <span class="synStatement">=&gt;</span> <span class="synConstant">1</span><span class="synStatement">,</span> <span class="synConstant">b</span> <span class="synStatement">=&gt;</span> <span class="synConstant">2</span>}<span class="synStatement">.</span><span class="synIdentifier">pick</span>(<span class="synStatement">*</span>)<span class="synStatement">;</span>  <span class="synComment"># &lt;a b b&gt; with probability 1/3</span>
                           <span class="synComment"># &lt;b a b&gt; with probability 1/3</span>
                           <span class="synComment"># &lt;b b a&gt; with probability 1/3</span>
{<span class="synConstant">a</span> <span class="synStatement">=&gt;</span> <span class="synConstant">1</span><span class="synStatement">,</span> <span class="synConstant">b</span> <span class="synStatement">=&gt;</span> <span class="synConstant">0.5</span>}<span class="synStatement">.</span><span class="synIdentifier">pick</span>(<span class="synStatement">*</span>) <span class="synComment"># dies, because the weights aren't all integers</span>
{<span class="synConstant">a</span> <span class="synStatement">=&gt;</span> <span class="synConstant">1</span><span class="synStatement">,</span> <span class="synConstant">b</span> <span class="synStatement">=&gt;</span> <span class="synConstant">0.5</span>}<span class="synStatement">.</span><span class="synIdentifier">pick</span>(<span class="synStatement">*,</span> <span class="synStatement">:</span><span class="synConstant">replace</span>)  <span class="synComment"># ok </span>
</pre>



<h2>What you can do</h2>

<p>Implement Hash.pick. It's ok if your patch doesn't cover all cases. It
would be nice if it supported non-integer weights.</p>

<p>Hint: this could be done by storing a list of accumulated weights, and a
list of keys.</p>

<pre>
{<span class="synConstant">a</span> <span class="synStatement">=&gt;</span> <span class="synConstant">1</span><span class="synStatement">,</span> <span class="synConstant">b</span> <span class="synStatement">=&gt;</span> <span class="synConstant">2.5</span><span class="synStatement">,</span> <span class="synConstant">c</span> <span class="synStatement">=&gt;</span> <span class="synConstant">1</span>}

<span class="synComment"># could translate to </span>
<span class="synSpecial">my</span> <span class="synIdentifier">@keys</span> <span class="synStatement">=</span> (<span class="synSpecial">'</span><span class="synConstant">a</span><span class="synSpecial">'</span><span class="synStatement">,</span> <span class="synSpecial">'</span><span class="synConstant">b</span><span class="synSpecial">'</span><span class="synStatement">,</span> <span class="synSpecial">'</span><span class="synConstant">c</span><span class="synSpecial">'</span>)<span class="synStatement">;</span>
<span class="synSpecial">my</span> <span class="synIdentifier">@accumulated_weights</span> <span class="synStatement">=</span> (<span class="synConstant">1</span><span class="synStatement">,</span> <span class="synConstant">3.5</span><span class="synStatement">,</span> <span class="synConstant">4.5</span>)<span class="synStatement">;</span>

<span class="synComment"># now pick a random number between 0 and 4.5,</span>
<span class="synComment"># find the next-highest index in @accumulated_weights</span>
<span class="synComment"># with a binary search, and then use that to obtain the key.</span>
</pre>

<p>Of course other schemes are fine too.</p>

<p>Second hint: because it takes quite some time to recompile Rakudo, it is 
probably easier to implement the actual logic in a function
in a normal source file first, and only later move it into src/core/Hash.pm.</p>

<h2>Submission</h2>

<p>Please submit your source code to the <a href="mailto:perl6-compiler@perl.org">perl6-compiler@perl.org</a> mailing
list (and put moritz@faui2k3.org on CC,
because the mailing list sometimes lack quite a bit).</p>

<p><strong>Update:</strong> there's one submission on the perl6-compiler
mailing list already, which looks pretty good.</p>



</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/contribute-now-hash-pick.html</id>
  </entry>
  <entry>
    <title>The State of Regex Modifiers in Rakudo</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/state-of-regex-modifiers.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">During the last one and a half month, I've been working on making regex
modifiers easily available in Rakudo.

The regex compiler itself has to support only a few of the adverbs that
can be applied to regexes; those include :ignorecase, :sigspace,
:ignoremark and :continue/:pos. NQP-rx, the regex engine that Rakudo uses
under the hood, supports those (except :ignoremark), so previously you
could write

if 'ABC' ~~ /:i abc/ {
    say "case insensitive match";}

But not

if 'ABC' ~~ rx:i/abc/ {
    say "case insensitive match";}

nor m:i/abc/, for that matter.

I've patched Rakudo to actually recognize those adverbs outside of the
regex, and also for s/// substitutions.

Another category of adverbs are those that apply to regex calls, not to
the compilation of a regex. Among those are :global/:g, :overlap/:ov,
:nth($n), :x. I've implemented those for substitutions, but implementing
them for m// turns out to be quite a bit harder.

The reason is the return value: each regex match returns a Match object,
which can store positional and named parts. S05 says that regex matches
with multiple results should return a single match object, with all
results as positional parts. It can be distinguished from a normal match
object by evaluating it in slice context... which Rakudo doesn't support
yet.

Now the subst method and thus s/// are implemented by calling
.match(:global, ...), and without slice context, it can't distinguish
between multiple matches, and a single match with subcaptures. And so my
changes to the global match broke the substitution, and I see no easy way
to fix it.

Anyway, here are a few examples of what works today:

$_ = 'ab12fg34';s:g/\d/X/;.say; # output: abXXfgXX
$_ = 'Hello, World';# :ii is the same as :samecases:ii/world/perl/;.say; # output: Hello, Perl$_ = 'I did not know that that work together';s:2nd/that/they/;.say; # output: I did not know that they work together</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>During the last one and a half month, I've been working on making regex
modifiers easily available in Rakudo.</p>

<p>The regex compiler itself has to support only a few of the adverbs that can
be applied to regexes; those include :ignorecase, :sigspace, :ignoremark and
:continue/:pos. NQP-rx, the regex engine that Rakudo uses under the hood,
supports those (except :ignoremark), so previously you could write</p>

<pre>
<span class="synStatement">if</span> <span class="synSpecial">'</span><span class="synConstant">ABC</span><span class="synSpecial">'</span> <span class="synStatement">~~</span> <span class="synSpecial">/</span><span class="synStatement">:</span><span class="synConstant">i abc</span><span class="synSpecial">/</span> {
    <span class="synIdentifier">say</span> <span class="synSpecial">"</span><span class="synConstant">case insensitive match</span><span class="synSpecial">"</span><span class="synStatement">;</span>
}
</pre>


<p>But not</p>

<pre>
<span class="synStatement">if</span> <span class="synSpecial">'</span><span class="synConstant">ABC</span><span class="synSpecial">'</span> <span class="synStatement">~~</span> <span class="synStatement">rx:</span><span class="synConstant">i</span><span class="synSpecial">/</span><span class="synConstant">abc</span><span class="synSpecial">/</span> {
    <span class="synIdentifier">say</span> <span class="synSpecial">"</span><span class="synConstant">case insensitive match</span><span class="synSpecial">"</span><span class="synStatement">;</span>
}
</pre>

<p>nor <code>m:i/abc/</code>, for that matter.</p>

<p>I've patched Rakudo to actually recognize those adverbs outside of the
regex, and also for <code>s///</code> substitutions.</p>

<p>Another category of adverbs are those that apply to regex calls, not to the
compilation of a regex. Among those are :global/:g, :overlap/:ov, :nth($n),
:x. I've implemented those for substitutions, but implementing them for
<code>m//</code> turns  out to be quite a bit harder.</p>

<p>The reason is the return value: each regex match returns a Match object,
which can store positional and named parts. <a href="http://pugscode.org/syn/S05.html">S05</a> says that regex matches
with multiple results should return a single match object, with all results as
positional parts. It can be distinguished from a normal match object by
evaluating it in slice context... which Rakudo doesn't support yet.</p>

<p>Now the <code>subst</code> method and thus <code>s///</code> are
implemented by calling <code>.match(:global, ...)</code>, and without slice
context, it can't distinguish between multiple matches, and a single match
with subcaptures. And so my changes to the global match broke the
substitution, and I see no easy way to fix it.</p>

<p>Anyway, here are a few examples of what works today:</p>

<pre>
<span class="synIdentifier">$_</span> <span class="synStatement">=</span> <span class="synSpecial">'</span><span class="synConstant">ab12fg34</span><span class="synSpecial">'</span><span class="synStatement">;</span>
<span class="synStatement">s:</span><span class="synConstant">g</span><span class="synSpecial">/\d/</span><span class="synConstant">X</span><span class="synSpecial">/</span><span class="synStatement">;</span>
<span class="synStatement">.</span><span class="synIdentifier">say</span><span class="synStatement">;</span> <span class="synComment"># output: abXXfgXX</span>


<span class="synIdentifier">$_</span> <span class="synStatement">=</span> <span class="synSpecial">'</span><span class="synConstant">Hello, World</span><span class="synSpecial">'</span><span class="synStatement">;</span>
<span class="synComment"># :ii is the same as :samecase</span>
<span class="synStatement">s:</span><span class="synConstant">ii</span><span class="synSpecial">/</span><span class="synConstant">world</span><span class="synSpecial">/</span><span class="synConstant">perl</span><span class="synSpecial">/</span><span class="synStatement">;</span>
<span class="synStatement">.</span><span class="synIdentifier">say</span><span class="synStatement">;</span> <span class="synComment"># output: Hello, Perl</span>

<span class="synIdentifier">$_</span> <span class="synStatement">=</span> <span class="synSpecial">'</span><span class="synConstant">I did not know that that work together</span><span class="synSpecial">'</span><span class="synStatement">;</span>
<span class="synStatement">s:</span><span class="synConstant">2nd</span><span class="synSpecial">/</span><span class="synConstant">that</span><span class="synSpecial">/</span><span class="synConstant">they</span><span class="synSpecial">/</span><span class="synStatement">;</span>
<span class="synStatement">.</span><span class="synIdentifier">say</span><span class="synStatement">;</span> <span class="synComment"># output: I did not know that they work together</span>
</pre>

 
</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/state-of-regex-modifiers.html</id>
  </entry>
  <entry>
    <title>Fixing Rakudo Memory Leaks</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/rakudo-memory-leaks.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Rakudo has been leaking memory for a few month. The other day, after some
nagging, Will Coleda identified a memory leak, and Tyler Curtis fixed it.

Now we can again make long-running processes with Rakudo. For example for
my talk at YAPC::EU I plotted a resonance curve. For that I needed to
start a new Rakudo process for every data point because it would leak so
badly that it died after processing a few data points. Now I recalculated
a whole curve in one process, with memory usage not exceeding 200MB of
virtual mem.

resonance curve

I also had some fun recalculating a mandelbrot fractal in a size that
would previously make Rakudo segfault or consume too much memory.

Mandelbrot fractal, rendered by Rakudo

(Rendered with colomon's mandelbrot code)).</div>
    </summary>
    <content type="html">

&lt;p&gt;Rakudo has been leaking memory for a few month. The other day, after some
nagging, Will Coleda identified a memory leak, and Tyler Curtis &lt;a href="http://github.com/rakudo/rakudo/commit/3a339ee8ab3a72867fe914ec9c689e1f5a890645"&gt;fixed
it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now we can again make long-running processes with Rakudo. For example for
my talk at YAPC::EU I plotted a &lt;a href="http://perlgeek.de/talks/2010/yapceu-p6-realworld/resonance.png"&gt;resonance 
curve&lt;/a&gt;. For that I needed to start a new Rakudo process for every data
point because it would leak so badly that it died after processing a few data
points. Now I recalculated a whole curve in one process, with memory usage not
exceeding 200MB of virtual mem.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://perlgeek.de/images/blog/res2.png" alt="resonance curve"&gt;&lt;/p&gt;

&lt;p&gt;I also had some fun recalculating a mandelbrot fractal in a size that would
previously make Rakudo segfault or consume too much memory.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://perlgeek.de/images/blog/mandel-color.png" alt="Mandelbrot fractal, rendered by Rakudo"&gt;&lt;/p&gt;

&lt;p&gt;(Rendered with &lt;a href="http://github.com/colomon/mandelbrot/"&gt;colomon's
mandelbrot code)&lt;/a&gt;).&lt;/p&gt;



</content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/rakudo-memory-leaks.html</id>
  </entry>
  <entry>
    <title> Number::Phone release </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_number-phone-release" type="text/html"/>
    <summary type="text">There's a new release, &lt;a href=http://www.cantrell.org.uk/david/tech/perl-modules/Number-Phone-1.58.tar.gz&gt;version 1.58&lt;/a&gt;, of Number::Phone, my set of perl modules for picking information out of phone numbers.  Changes from the previous release are that Mayotte, Reunion and Comoros can't decide which country is which, and there's the usual updates to the database of UK numbers, mostly to support the &lt;a href=http://www.ofcom.org.uk/media/news/2007/02/nr_20070213b&gt;new 03 numbers&lt;/a&gt;.
</summary>
    <content type="text">There's a new release, &lt;a href=http://www.cantrell.org.uk/david/tech/perl-modules/Number-Phone-1.58.tar.gz&gt;version 1.58&lt;/a&gt;, of Number::Phone, my set of perl modules for picking information out of phone numbers.  Changes from the previous release are that Mayotte, Reunion and Comoros can't decide which country is which, and there's the usual updates to the database of UK numbers, mostly to support the &lt;a href=http://www.ofcom.org.uk/media/news/2007/02/nr_20070213b&gt;new 03 numbers&lt;/a&gt;.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_number-phone-release</id>
  </entry>
  <entry>
    <title> Wikipedia handheld proxy </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_wikipedia-proxy" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">I got irritated at how hard it was to use Wikipedia on my Treo. There's
so much rubbish splattered around their pages that it Just Doesn't Work
on such a small screen. Given that no alternatives seemed to be available
- at least, Google couldn't find any - I decided to write my own
Wikipedia handheld proxy.

It strips away all the useless rubbish that normally surrounds Wikipedia
pages, as well as things like the editing functions which are also hard
to use on portable devices. Internally, it's implemented using perl, LWP,
and mod_perl, and is hosted by Keyweb.de.</div>
    </summary>
    <content type="text">I got irritated at how hard it was to use &lt;a href="http://en.wikipedia.org/"&gt;Wikipedia&lt;/a&gt; on my Treo.  There's so much rubbish splattered around their pages that it Just Doesn't Work on such a small screen.  Given that no alternatives seemed to be available - at least, Google couldn't find any - I decided to write my own &lt;a href="http://wikiproxy.cantrell.org.uk/"&gt;Wikipedia handheld proxy&lt;/a&gt;.&lt;p&gt;It strips away all the useless rubbish that normally surrounds Wikipedia pages, as well as things like the editing functions which are also hard to use on portable devices.  Internally, it's implemented using &lt;a href="http://www.perl.org/"&gt;perl&lt;/a&gt;, &lt;a href="http://search.cpan.org/~gaas/libwww-perl-5.806/"&gt;LWP&lt;/a&gt;, and &lt;a href="http://search.cpan.org/~pgollucci/mod_perl-2.0.3/"&gt;mod_perl&lt;/a&gt;, and is hosted by &lt;a href="http://www.keyweb.de/vrsrds/index.shtml"&gt;Keyweb.de&lt;/a&gt;.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_wikipedia-proxy</id>
  </entry>
  <entry>
    <title> CPANdeps upgrade </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_cpandeps-upgraded-to-mysql" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">While you won't notice any changes, there have been biiiig upgrades at
CPANdeps. Here's the diff.

Until now, it's used a SQLite database of test results that I downloaded
every day and then mangled a bit to do things like add some necessary
indices, figure out which reports are from dev versions of perl, and so
on. That worked really well back in the summer of 2007, when there were
only half a million reports in the database. I started worrying a bit at
the beginning of 2009 when we hit 3 million, but the update happened
overnight so I didn't care. But now that we've got over 6 million
reports, the update would take anywhere between 8 and 14 hours. Not only
is that not sustainable given the current growth rate, it also hurts the
other users on that machine, because almost all of that time is spent
waiting for disk I/O - which means that they're also waiting for the
disk. On top of that, when you have big databases, a SQLite CGI ain't a
great idea because indices have to be fetched from disk every time, so
reads pound the disk too. Doubleplusungood!

Fun fact: SQLite is great for prototyping, but it doesn't scale :-)

So now it uses MySQL. Having a database daemon running all the time means
that there's now some caching, so reads are quicker. In addition, given
that I can't just simply fiddle with the structure of the database that I
download to produce what I want, and instead have to import the data into
MySQL, it now only imports new records, so the daily update takes only a
few seconds.

I also re-jigged the structure of how it caches test results. Instead of
being all in one directory with hundreds of thousands of files, they're
split into a hierarchy. This probably won't have any significant effect
on normal operations, but it will certainly make it faster for me to
navigate around and see what's going on when people submit bug reports!</div>
    </summary>
    <content type="text">While you won't notice any changes, there have been biiiig upgrades at &lt;a href="http://deps.cpantesters.org"&gt;CPANdeps&lt;/a&gt;.  &lt;a href="http://www.cantrell.org.uk/cgit/cgit.cgi/cpandeps/diff/?id=2fa3ffb8d3b0597afb7a35f473086c82b8a07335&amp;amp;id2=8df033031c2fcd9243152d35e5d8336d60264ecc"&gt;Here's the diff&lt;/a&gt;.&lt;p&gt;Until now, it's used a SQLite database of test results that I downloaded every day and then mangled a bit to do things like add some necessary indices, figure out which reports are from dev versions of perl, and so on.  That worked really well back in the summer of 2007, when there were only half a million reports in the database.  I started worrying a bit at the beginning of 2009 when we hit 3 million, but the update happened overnight so I didn't care.  But now that we've got over 6 million reports, the update would take anywhere between 8 and 14 hours.  Not only is that not sustainable given the current growth rate, it also hurts the other users on that machine, because almost all of that time is spent waiting for disk I/O - which means that they're also waiting for the disk.  On top of that, when you have big databases, a SQLite CGI ain't a great idea because indices have to be fetched from disk every time, so reads pound the disk too.  Doubleplusungood!&lt;p&gt;Fun fact: SQLite is great for prototyping, but it doesn't scale :-)&lt;p&gt;So now it uses MySQL.  Having a database daemon running all the time means that there's now some caching, so reads are quicker.  In addition, given that I can't just simply fiddle with the structure of the database that I download to produce what I want, and instead have to import the data into MySQL, it now only imports new records, so the daily update takes only a few seconds.&lt;p&gt;I also re-jigged the structure of how it caches test results.  Instead of being all in one directory with hundreds of thousands of files, they're split into a hierarchy.  This probably won't have any significant effect on normal operations, but it will certainly make it faster for me to navigate around and see what's going on when people submit bug reports!
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_cpandeps-upgraded-to-mysql</id>
  </entry>
  <entry>
    <title>Notes from the YAPC::EU 2010 Rakudo hackathon</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/notes-from-yapc-hackathon.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">At YAPC::EU 2010 we had a long discussion about Perl 6, Rakudo and
related matters. Here are some (very incomplete) notes of the ongoing
discussions and results.


Attendees
---------

Patrick Michaud, Jonathan Worthington, Carl Mäsak, Moritz Lenz, Gabor
Szabo, and a fluctuation of other Perl 6 hackers.


Speed
-----

What can we do to improve Rakudo's performance?

jnthn's grant proposal for a low-level meta object protocol

      See
      http://news.perlfoundation.org/2010/07/hague-grant-application-meta-m.html.
      Will probably bring the biggest speed improvement of all options we
      have under our control

Rakudo built-in optimizations

      Most Rakudo built-ins are written for correctness first, and
      without a good feeling for what constructs are fast and what
      aren't. A thorough review (and preferably profiling) could bring
      decent speed improvements, as the case of int ranges showed.

Garbage collector

      Parrot's GC is... suboptimal. To be gentle.

Optimization framework

      We will try to convince people that Tyler Curtis' optimization
      framework for PAST and POST should be shipped with parrot (probably
      compile PIRs in ext/, just like NQP-rx does it now). Using that, we
      can do constant folding

Moving stuff to compile time

      Number parsing needs to be moved to compile time.


What do we need to keep hacking?
--------------------------------

Brought up by Gabor

Money 

      We do much volunteer work, but when we get funding, we can devote
      more time to hacking

Travel/Conferences

      We'd like to get together a few times (2? 3? 4?) a year, in real
      life.

      Funding and organization would be very welcome

Short-time funding

      It would be nice to have a way to have funding available much more
      quickly than through the usual grant process, which tends to be
      longish.


Rakudo Star feedback
--------------------

Good: It worked. It did what we wanted it to.

Bad:

  * 

    It lacked a module installer (It shipped proto, but didn't install
    it).

  * 

    Compilation takes too much memory. pmichaud will try a hack to split
    the setting, which would solve that problem.

  * 

    There was some discussion about the roles + outer scopes bugs, which
    was way over my head. It seems to be related to the fact that parrot
    has two outer chains for nested blocks: one at compile time, one at
    runtime. Since role methods are flattened into classes, there compile
    time outer block is actually different than where it runs, and that
    screws up ... forget it, somebody else must describe it.

  * 

    Lack of modules - doesn't seem to bee a big problem

  * 

    Lack of features: not a big problem.

    Biggest complaints: missing perl6doc. Missing non-blocking IO, binary
    file support.

  * 

    Prefix paths with spaces are not supported :(

    jnthn: "I actually tried to write a C program that binary patches the
    perl6 executable to allow spaces in path names. It almost worked."

  * 

    We will try to advocate compilation to PBC, not PIR - once that's
    supported.


Proto/Pls
---------

Proto needs to be end-of-life'd.

It confuses people that there are two different project lists, and the
lists diverge.

We would like to decentralize the module list somehow. Still open how.

People don't release Perl 6 modules, because there's no need so far, and
it's tedious to add the version name in each .pm/.pm6 file. We might need
to come up with a clever idea for that.


Backend diversity
-----------------

Additionally to the parrot backend, we want to run Perl 6 code on other
virtual machines.

jnthn will work on a .NET/CLR port. He wants to prototype the new
low-level class composition code in .NET anyway, which will provide the
basic foundations for running NQP.

pmichaud wants to explore javascript on V8 as a possible backend. "I
managed PIR, I'll certainly manage javascript" :-)

  * 

    Huge time sink, but still worth doing it

  * 

    Apache runtime library might be worth looking into

  * 

    risks: stalled refactors are dangerous (see: PHP 6, cardinal (the
    ruby-on-parrot compiler))

    We want to avoid fragmentation into many subprojects

  * 

    We want to increase the number of possible contributors to rakudo by
    enabling non-parrot people to contribute.

  * 

    Code for different backends will be maintained as directories in
    Rakudo and NQP, not as branches.

  * 

    pir:: things will be hidden behind an nqp:: abstraction layer


Attracting contributors
-----------------------

Moritz wants to continue with the "weekly" challenges, but runs out of
ideas. Add ideas to http://svn.pugscode.org/pugs/misc/helpnow/README.

We will try to apply patches faster, thus encouraging people who already
did the first step.


Documentation
-------------

  * 

    in p5 pod for now, so that people can contribute easily

  * 

    masak and szabgab expressed interest in working on pod6 tools</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>At YAPC::EU 2010 we had a long discussion about Perl 6, Rakudo and related
matters. Here are some (very incomplete) notes of the ongoing discussions and
results.</p>

<h2 id="attendees">Attendees</h2>

<p>Patrick Michaud, Jonathan Worthington, Carl Mäsak, Moritz Lenz, Gabor
Szabo, and a fluctuation of other Perl 6 hackers.</p>

<h2 id="speed">Speed</h2>
<p>What can we do to improve Rakudo's performance?</p>
<dl>
<dt><strong><a name="jnthn_s_grant_proposal_for_a_low_level_meta_object_protocol" class="item">jnthn's grant proposal for a low-level meta object protocol</a></strong></dt>

<dd>
<p>See
<a href="http://news.perlfoundation.org/2010/07/hague-grant-application-meta-m.html">http://news.perlfoundation.org/2010/07/hague-grant-application-meta-m.html</a>.
Will probably bring the biggest speed improvement of all options we have under
our control</p>
</dd>
<dt><strong><a name="rakudo_built_in_optimizations" class="item">Rakudo built-in optimizations</a></strong></dt>

<dd>
<p>Most Rakudo built-ins are written for correctness first, and without a good
feeling for what constructs are fast and what aren't. A thorough review (and
preferably profiling) could bring decent speed improvements, as the case of
int ranges showed.</p>
</dd>
<dt><strong><a name="garbage_collector" class="item">Garbage collector</a></strong></dt>

<dd>
<p>Parrot's GC is... suboptimal. To be gentle.</p>
</dd>
<dt><strong><a name="optimization_framework" class="item">Optimization framework</a></strong></dt>

<dd>
<p>We will try to convince people that Tyler Curtis' optimization framework for
PAST and POST should be shipped with parrot (probably compile PIRs in <code>ext/</code>,
just like NQP-rx does it now). Using that, we can do constant folding</p>
</dd>
<dt><strong><a name="moving_stuff_to_compile_time" class="item">Moving stuff to compile time</a></strong></dt>

<dd>
<p>Number parsing needs to be moved to compile time.</p>
</dd>
</dl>

<h2 id="what_do_we_need_to_keep_hacking">What do we need to keep hacking?</h2>
<p>Brought up by Gabor</p>
<dl>
<dt><strong><a name="money" class="item">Money</a></strong></dt>

<dd>
<p>We do much volunteer work, but when we get funding, we can devote more time to
hacking</p>
</dd>
<dt><strong><a name="travel_conferences" class="item">Travel/Conferences</a></strong></dt>

<dd>
<p>We'd like to get together a few times (2? 3? 4?) a year, in real life.</p>
<p>Funding and organization would be very welcome</p>
</dd>
<dt><strong><a name="short_time_funding" class="item">Short-time funding</a></strong></dt>

<dd>
<p>It would be nice to have a way to have funding available much more quickly
than through the usual grant process, which tends to be longish.</p>
</dd>
</dl>
<p>
</p>
<h2 id="rakudo_star_feedback">Rakudo Star feedback</h2>
<p>Good: It worked. It did what we wanted it to.</p>
<p>Bad:</p>
<ul>
<li>
<p>It lacked a module installer (It shipped proto, but didn't install it).</p>
</li>
<li>
<p>Compilation takes too much memory. pmichaud will try a hack to split the
setting, which would solve that problem.</p>
</li>
<li>
<p>There was some discussion about the roles + outer scopes bugs, which was way
over my head. It seems to be related to the fact that parrot has two outer
chains for nested blocks: one at compile time, one at runtime. Since role
methods are flattened into classes, there compile time outer block is actually
different than where it runs, and that  screws up ... forget it, somebody else must describe it.</p>
</li>
<li>
<p>Lack of modules - doesn't seem to bee a big problem</p>
</li>
<li>
<p>Lack of features: not a big problem.</p>
<p>Biggest complaints: missing perl6doc. Missing non-blocking IO, binary file
support.</p>
</li>
<li>
<p>Prefix paths with spaces are not supported :(</p>
<p>jnthn: "I actually tried to write a C program that binary patches the perl6
executable to allow spaces in path names. It almost worked."</p>
</li>
<li>
<p>We will try to advocate compilation to PBC, not PIR - once that's supported.</p>
</li>
</ul>

<h2 id="proto_pls">Proto/Pls</h2>
<p>Proto needs to be end-of-life'd.</p>
<p>It confuses people that there are two different project lists, and the lists
diverge.</p>
<p>We would like to decentralize the module list somehow. Still open how.</p>

<p>People don't release Perl 6 modules, because there's no need so far, and
it's tedious to add the version name in each .pm/.pm6 file. We might need to
come up with a clever idea for that.</p>

<h2 id="backend_diversity">Backend diversity</h2>
<p>Additionally to the parrot backend, we want to run Perl 6 code on other
virtual machines.</p>
<p>jnthn will work on a .NET/CLR port. He wants to prototype the new low-level
class composition code in .NET anyway, which will provide the basic
foundations for running NQP.</p>
<p>pmichaud wants to explore javascript on V8 as a possible backend. "I managed
PIR, I'll certainly manage javascript" :-)</p>
<ul>
<li>
<p>Huge time sink, but still worth doing it</p>
</li>
<li>
<p>Apache runtime library might be worth looking into</p>
</li>
<li>
<p>risks: stalled refactors are dangerous (see: PHP 6, cardinal (the
ruby-on-parrot compiler))</p>
<p>We want to avoid fragmentation into many subprojects</p>
</li>
<li>
<p>We want to increase the number of possible contributors to rakudo by
enabling non-parrot people to contribute.</p>
</li>
<li>
<p>Code for different backends will be maintained as directories in Rakudo and
NQP, not as branches.</p>
</li>
<li>
<p>pir:: things will be hidden behind an nqp:: abstraction layer</p>
</li>
</ul>

<h2 id="attracting_contributors">Attracting contributors</h2>
<p>Moritz wants to continue with the "weekly" challenges, but runs out of ideas.
Add ideas to <a href="http://svn.pugscode.org/pugs/misc/helpnow/README">http://svn.pugscode.org/pugs/misc/helpnow/README</a>.</p>
<p>We will try to apply patches faster, thus encouraging people who already did
the first step.</p>

<h2 id="documentation">Documentation</h2>
<ul>
<li>
<p>in p5 pod for now, so that people can contribute easily</p>
</li>
<li>
<p>masak and szabgab expressed interest in working on pod6 tools</p>
</li>
</ul>

 
</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/notes-from-yapc-hackathon.html</id>
  </entry>
  <entry>
    <title> CPANdeps </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_cpandeps" type="text/html"/>
    <summary type="html">&lt;a href=http://cpandeps.cantrell.org.uk/&gt;CPANdeps&lt;/a&gt; now lets you filter test results by perl version number, and also knows what modules were in core in which versions of perl.  Hurrah!
</summary>
    <content type="html">&lt;a href=http://cpandeps.cantrell.org.uk/&gt;CPANdeps&lt;/a&gt; now lets you filter test results by perl version number, and also knows what modules were in core in which versions of perl.  Hurrah!
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_cpandeps</id>
  </entry>
  <entry>
    <title> YAPC::Europe 2007 report: day 2 </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2007-day-2" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">A day of not many talks, but lots of cool stuff. Damian was his usual
crazy self, and MJD's talk on building parsers was really good. Although
I probably won't use those techniques at work as functional programming
seems to scare people.

The conference dinner at a Heuriger on the outskirts of Vienna was great.
The orga-punks had hired a small fleet of buses to get us there and back,
and one of the sponsors laid on a great buffet. The local wine was pretty
damned fine too, and then the evening de-generated into Schnapps, with
toasts to Her Majesty, to her splendid navy, and to The Village People.

It wasn't all debauchery in the evening though - on the bus, I had a very
useful chat with Philippe about Net::Proxy, and re-designing it to make
it easier to create new connectors for it.</div>
    </summary>
    <content type="text">A day of not many talks, but lots of cool stuff.  Damian was his usual crazy self, and MJD's talk on building parsers was really good.  Although I probably won't use those techniques at work as functional programming seems to scare people.&lt;p&gt;The conference dinner at a &lt;a href="http://wikiproxy.cantrell.org.uk/Heuriger"&gt;Heuriger&lt;/a&gt; on the outskirts of Vienna was great.  The orga-punks had hired a small fleet of buses to get us there and back, and one of the sponsors laid on a great buffet.  The local wine was pretty damned fine too, and then the evening de-generated into Schnapps, with toasts to Her Majesty, to her splendid navy, and to The Village People.&lt;p&gt;It wasn't all debauchery in the evening though - on the bus, I had a very useful chat with &lt;a href="http://www.bruhat.net/"&gt;Philippe&lt;/a&gt; about &lt;a href="http://search.cpan.org/~book/Net-Proxy-0.08/"&gt;Net::Proxy&lt;/a&gt;, and re-designing it to make it easier to create new connectors for it.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2007-day-2</id>
  </entry>
  <entry>
    <title> YAPC::Europe 2006 report: day 3 </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2006-day-3" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">There were quite a few interesting talks in the morning, especially
Ivor's one on packaging perl applications. Oh, and mine about rsnapshot,
of course, in which people laughed at the right places and I judged the
length of it just right, finishing with a couple of minutes left for
questions.

At the traditional end-of-YAPC auction, I avoided spending my usual
stupid amounts of money on stupid things, which was nice. Obviously the
hundred quid I put in to buying the hair style of next year's organisers
wasn't stupid. Oh no. Definitely not.

An orange mohican will suit Domm beautifully.</div>
    </summary>
    <content type="text">There were quite a few interesting talks in the morning, especially Ivor's one on packaging perl applications.  Oh, and mine about rsnapshot, of course, in which people laughed at the right places and I judged the length of it just right, finishing with a couple of minutes left for questions.&lt;p&gt;At the traditional end-of-YAPC auction, I avoided spending my usual stupid amounts of money on stupid things, which was nice.  Obviously the hundred quid I put in to buying the hair style of next year's organisers wasn't stupid.  Oh no.  Definitely not.&lt;p&gt;An orange mohican will suit &lt;a href="http://static.flickr.com/9/11370395_031596292a_m.jpg"&gt;Domm&lt;/a&gt; beautifully.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2006-day-3</id>
  </entry>
  <entry>
    <title> YAPC::Europe 2007 report: day 3 </title>
    <link rel="alternate" href=" http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2007-day-3" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">My Lightning Talk on cpandeps went down really well, although as José
pointed out, I need to fix it to take account of File::Copy being broken.
I also need to talk to Domm after the conference is over to see if I can
get dependency information from CPANTS as well as from META.yml files.

There were lots of other good lightning talks. Dmitri Karasik's regexes
for doing OCR, Juerd Waalboer's Unicode::Semantics, and Renée Bäcker's
Win32::GuiTest were especially noteworthy.

Richard Foley's brief intro to the perl debugger was also useful.
Unfortunately Hakim Cassimally's talk was about debugging web
applications, which I'd not noticed on the schedule, so I didn't stay for
that.

And finally, Mark Fowler's grumble about why perl sucks (and what to do
about it) had a few interesting little things in it. I am having vaguely
sick ideas about mixing some of that up with an MJD-stylee parser.

At the auction I paid €250 to have the Danish organisers of next year's
YAPC::Europe wear the Swedish flag on their foreheads. This, I should
point out, was Greg's idea. I would never be so evil on my own.</div>
    </summary>
    <content type="text">My &lt;a href="http://www.justanotherperlhacker.org/lightning/index.shtml"&gt;Lightning Talk&lt;/a&gt; on &lt;a href="http://cpandeps.cantrell.org.uk/"&gt;cpandeps&lt;/a&gt; went down really well, although as Jos&amp;eacute; pointed out, I need to fix it to take account of &lt;a href="http://cpandeps.cantrell.org.uk/?module=File%3A%3ACopy"&gt;File::Copy&lt;/a&gt; being &lt;a href="http://abigail1.hates-software.com/2005/09/21/0692681a.html"&gt;broken&lt;/a&gt;.  I also need to talk to Domm after the conference is over to see if I can get dependency information from CPANTS as well as from META.yml files.&lt;p&gt;There were lots of other good lightning talks.  Dmitri Karasik's regexes for doing OCR, Juerd Waalboer's &lt;a href="http://search.cpan.org/~juerd/Unicode-Semantics-1.00/"&gt;Unicode::Semantics&lt;/a&gt;, and Ren&amp;eacute;e B&amp;auml;cker's &lt;a href="http://search.cpan.org/~ctrondlp/Win32-GuiTest-1_50.5/"&gt;Win32::GuiTest&lt;/a&gt; were especially noteworthy.&lt;p&gt;Richard Foley's brief intro to the perl debugger was also useful.  Unfortunately Hakim Cassimally's talk was about debugging &lt;em&gt;web&lt;/em&gt; applications, which I'd not noticed on the schedule, so I didn't stay for that.&lt;p&gt;And finally, Mark Fowler's grumble about why perl sucks (and what to do about it) had a few interesting little things in it.  I am having vaguely sick ideas about mixing some of that up with an MJD-stylee parser.&lt;p&gt;At the auction I paid &amp;euro;250 to have the Danish organisers of next year's YAPC::Europe wear the Swedish flag on their foreheads.  This, I should point out, was &lt;a href="http://drinkbroken.typepad.com/"&gt;Greg&lt;/a&gt;'s idea.  I would never be so evil on my own.
</content>
    <author>
      <name> david </name>
    </author>
    <id>tag:perlsphere.net,2006: http://www.cantrell.org.uk/david/journal/index.pl/id_yapc-europe-2007-day-3</id>
  </entry>
  <entry>
    <title>Currying</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-5-to-6/28-currying.html" type="text/html"/>
    <summary type="text">NAME

"Perl 5 to 6" Lesson 28 - Currying


SYNOPSIS

  use v6;
  
  my &amp;f := &amp;substr.assuming('Hello, World');
  say f(0, 2);                # He
  say f(3, 2);                # lo
  say f(7);                   # World
  
  say &lt;a b c&gt;.map: * x 2;     # aabbcc
  say &lt;a b c&gt;.map: *.uc;      # ABC
  for ^10 {
      print &lt;R G B&gt;.[$_ % *]; # RGBRGBRGBR
  }


DESCRIPTION

Currying or partial application is the process of generating a function
from another function or method by providing only some of the arguments.
This is useful for saving typing, and when you want to pass a callback to
another function.

Suppose you want a function that lets you extract substrings from "Hello,
World" easily. The classical way of doing that is writing your own
function:

  sub f(*@a) {
      substr('Hello, World', |@a)
  }

Currying with assuming

Perl 6 provides a method assuming on code objects, which applies the
arguments passed to it to the invocant, and returns the partially applied
function.

  my &amp;f := &amp;substr.assuming('Hello, World');

Now f(1, 2) is the same as substr('Hello, World', 1, 2).

assuming also works on operators, because operators are just subroutines
with weird names. To get a subroutine that adds 2 to whatever number gets
passed to it, you could write

  my &amp;add_two := &amp;infix:&lt;+&gt;.assuming(2);

But that's tedious to write, so there's another option.

Currying with the Whatever-Star

  my &amp;add_two := * + 2;
  say add_two(4);         # 6

The asterisk, called Whatever, is a placeholder for an argument, so the
whole expression returns a closure. Multiple Whatevers are allowed in a
single expression, and create a closure that expects more arguments, by
replacing each term * by a formal parameter. So * * 5 + * is equivalent
to -&gt; $a, $b { $a * 5 + $b }.

  my $c = * * 5 + *;
  say $c(10, 2);                # 52

Note that the second * is an infix operator, not a term, so it is not
subject to Whatever-currying.

The process of lifting an expression with Whatever stars into a closure
is driven by syntax, and done at compile time. This means that

  my $star = *;
  my $code = $star + 2

does not construct a closure, but instead dies with a message like

  Can't take numeric value for object of type Whatever

Whatever currying is more versatile than .assuming, because it allows to
curry something else than the first argument very easily:

  say  ~(1, 3).map: 'hi' x *    # hi hihihi

This curries the second argument of the string repetition operator infix
x, so it returns a closure that, when called with a numeric argument,
produces the string hi as often as that argument specifies.

The invocant of a method call can also be Whatever star, so

  say &lt;a b c&gt;.map: *.uc;      # ABC

involves a closure that calls the uc method on its argument.


MOTIVATION

Perl 5 could be used for functional programming, which has been
demonstrated in Mark Jason Dominus' book Higher Order Perl.

Perl 6 strives to make it even easier, and thus provides tools to make
typical constructs in functional programming easily available. Currying
and easy construction of closures is a key to functional programming, and
makes it very easy to write transformation for your data, for example
together with map or grep.


SEE ALSO

http://perlcabal.org/syn/S02.html#Built-In_Data_Types

http://hop.perl.plover.com/

http://en.wikipedia.org/wiki/Currying</summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<h3><a class="u" href="#___top" title="click to go to top of document" name="NAME">NAME</a></h3>

<p>"Perl 5 to 6" Lesson 28 - Currying</p>

<h3><a class="u" href="#___top" title="click to go to top of document" name="SYNOPSIS">SYNOPSIS</a></h3>

<pre>  use v6;
  
  my &amp;f := &amp;substr.assuming('Hello, World');
  say f(0, 2);                # He
  say f(3, 2);                # lo
  say f(7);                   # World
  
  say &lt;a b c&gt;.map: * x 2;     # aabbcc
  say &lt;a b c&gt;.map: *.uc;      # ABC
  for ^10 {
      print &lt;R G B&gt;.[$_ % *]; # RGBRGBRGBR
  }</pre>

<h3><a class="u" href="#___top" title="click to go to top of document" name="DESCRIPTION">DESCRIPTION</a></h3>

<p><i>Currying</i> or <i>partial application</i> is the process of generating a function from another function or method by providing only some of the arguments. This is useful for saving typing, and when you want to pass a callback to another function.</p>

<p>Suppose you want a function that lets you extract substrings from <code>"Hello, World"</code> easily. The classical way of doing that is writing your own function:</p>

<pre>  sub f(*@a) {
      substr('Hello, World', |@a)
  }</pre>

<h4><a class="u" href="#___top" title="click to go to top of document" name="Currying_with_assuming">Currying with <code>assuming</code></a></h4>

<p>Perl 6 provides a method <code>assuming</code> on code objects, which applies the arguments passed to it to the invocant, and returns the partially applied function.</p>

<pre>  my &amp;f := &amp;substr.assuming('Hello, World');</pre>

<p>Now <code>f(1, 2)</code> is the same as <code>substr('Hello, World', 1, 2)</code>.</p>

<p><code>assuming</code> also works on operators, because operators are just subroutines with weird names. To get a subroutine that adds 2 to whatever number gets passed to it, you could write</p>

<pre>  my &amp;add_two := &amp;infix:&lt;+&gt;.assuming(2);</pre>

<p>But that's tedious to write, so there's another option.</p>

<h4><a class="u" href="#___top" title="click to go to top of document" name="Currying_with_the_Whatever-Star">Currying with the Whatever-Star</a></h4>

<pre>  my &amp;add_two := * + 2;
  say add_two(4);         # 6</pre>

<p>The asterisk, called <i>Whatever</i>, is a placeholder for an argument, so the whole expression returns a closure. Multiple Whatevers are allowed in a single expression, and create a closure that expects more arguments, by replacing each term <code>*</code> by a formal parameter. So <code>* * 5 + *</code> is equivalent to <code>-&gt; $a, $b { $a * 5 + $b }</code>.</p>

<pre>  my $c = * * 5 + *;
  say $c(10, 2);                # 52</pre>

<p>Note that the second <code>*</code> is an infix operator, not a term, so it is not subject to Whatever-currying.</p>

<p>The process of lifting an expression with Whatever stars into a closure is driven by syntax, and done at compile time. This means that</p>

<pre>  my $star = *;
  my $code = $star + 2</pre>

<p>does not construct a closure, but instead dies with a message like</p>

<pre>  Can't take numeric value for object of type Whatever</pre>

<p>Whatever currying is more versatile than <code>.assuming</code>, because it allows to curry something else than the first argument very easily:</p>

<pre>  say  ~(1, 3).map: 'hi' x *    # hi hihihi</pre>

<p>This curries the second argument of the string repetition operator infix <code>x</code>, so it returns a closure that, when called with a numeric argument, produces the string <code>hi</code> as often as that argument specifies.</p>

<p>The invocant of a method call can also be Whatever star, so</p>

<pre>  say &lt;a b c&gt;.map: *.uc;      # ABC</pre>

<p>involves a closure that calls the <code>uc</code> method on its argument.</p>

<h3><a class="u" href="#___top" title="click to go to top of document" name="MOTIVATION">MOTIVATION</a></h3>

<p>Perl 5 could be used for functional programming, which has been demonstrated in Mark Jason Dominus' book <i>Higher Order Perl</i>.</p>

<p>Perl 6 strives to make it even easier, and thus provides tools to make typical constructs in functional programming easily available. Currying and easy construction of closures is a key to functional programming, and makes it very easy to write transformation for your data, for example together with <code>map</code> or <code>grep</code>.</p>

<h3><a class="u" href="#___top" title="click to go to top of document" name="SEE_ALSO">SEE ALSO</a></h3>

<p><a href="http://perlcabal.org/syn/S02.html#Built-In_Data_Types" class="podlinkurl">http://perlcabal.org/syn/S02.html#Built-In_Data_Types</a></p>

<p><a href="http://hop.perl.plover.com/" class="podlinkurl">http://hop.perl.plover.com/</a></p>

<p><a href="http://en.wikipedia.org/wiki/Currying" class="podlinkurl">http://en.wikipedia.org/wiki/Currying</a></p>

 </div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-5-to-6/28-currying.html</id>
  </entry>
  <entry>
    <title>My first YAPC - YAPC::EU 2010 in Pisa</title>
    <link rel="alternate" href="http://perlgeek.de/blog-en/perl-6/my-first-yapc.html" type="text/html"/>
    <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">This week I attended my first international Perl conference, the YAPC::EU
2010 in Pisa, Italy. I very much enjoyed it.

I arrived a few days earlier, and spent the time visiting Pisa, talking
with old and new friends, and did some collaborative hacking. I
especially enjoyed meeting people with whom I had had only contact via
Internet so far, and found all of them to be very nice in meat space.

On Tuesday, the day before the conference started officially, a group of
Perl 6 hackers met and discussed topics around Perl 6 and Rakudo. I
recall talking with Patrick Michaud, Jonathan Worthington, Carl Mäsak,
Paweł Murias, Gabor Szabo, smash (I can't spell his full name correctly
from memory, sorry for that), and we have a very productive discussion
(about 5 hours or so). Notes from the discussion will be published later.

On Wednesday the actual conference started, and there were plenty of very
interesting talks, and very amusing lightning talks. I generally like the
humor that is widespread in the Perl community.

On Thursday I continued to attend nice and informative talks, and also
gave a talk on my own. It was about physical modelling with Perl 6, and
in general the feedback was very positive, and somebody even commented
that while he didn't understand everything I wrote, it reminded him that
it was important to learn Perl 6 now. Win \o/. (There was also some
criticism, but from somebody who apparently hasn't read the abstract; the
"write-only" meme seems to apply to perl bloggers, not code). You can
find the slides to my talk here.

Firday was the day of my departure too - sadly I had to leave after the
first talk, and missed the rest of the day, including the closing keynote
by mst (I did attend a talk of his) and the traditional auction.

I especially enjoyed...

  * meeting Patrick, Larry, Gloria, Aaron, Gabor and many others for the
    first time in real-life

  * a thorough, high-bandwith discussion with Larry, Jonathan, Patrick
    and Carl about p6 spec questions, and the Perl 6 discussions
    mentioned earlier

  * a lightning talk imagine you're in a data center with no connection
    to the outside, and you accidentally executed chmod -x chmod. What
    would you do?

  * good Italian Pizzas (although I had to wait 50 minutes for one of
    them)

  * A talk by Tim Bunce, where he demonstrated database access in Perl 6
    both with libraries that do native calls, and through the Blizkost
    project using the Perl 5 DBI/DBD::SQLite modules

  * the general relaxed attitude in the Perl community, where people help
    each other, and don't seem to be easily offended (at least in meat
    space :)

  * being surrounded by many other geeks

  * realizing that several Perl hackers brought their family to the
    conference

It was an overwhelming experience, and I look forward to my next YAPC!</div>
    </summary>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">

<p>This week I attended my first international Perl conference, the <a href="http://conferences.yapceurope.org/ye2010/index.html">YAPC::EU 2010 in
Pisa, Italy</a>. I very much enjoyed it.</p>

<p>I arrived a few days earlier, and spent the time visiting Pisa, talking
with old and new friends, and did some collaborative hacking. I especially
enjoyed meeting people with whom I had had only contact via Internet so far,
and found all of them to be very nice in meat space.</p>

<p>On Tuesday, the day before the conference started officially, a group of
Perl 6 hackers met and discussed topics around Perl 6 and Rakudo. I recall
talking with Patrick Michaud, Jonathan Worthington, Carl Mäsak, Paweł
Murias, Gabor Szabo, smash (I can't spell his full name correctly from memory,
sorry for that), and we have a very productive discussion (about 5 hours or
so). Notes from the discussion will be published later.</p>

<p>On Wednesday the actual conference started, and there were plenty of very
interesting talks, and very amusing lightning talks. I generally like the
humor that is widespread in the Perl community.</p>

<p>On Thursday I continued to attend nice and informative talks, and also gave
a talk on my own. It was about physical modelling with Perl 6, and in general
the feedback was very positive, and somebody even commented that while he
didn't understand everything I wrote, it reminded him that it was important to
learn Perl 6 now. Win \o/. (There was also some criticism, but from somebody
who apparently hasn't read <a href="http://conferences.yapceurope.org/ye2010/talk/2949">the abstract</a>;
the "write-only" meme seems to apply to perl bloggers, not code). You can find
<a href="http://perlgeek.de/talks/2010/yapceu-p6-realworld/">the slides
to my talk here.</a></p>

<p>Firday was the day of my departure too - sadly I had to leave after the
first talk, and missed the rest of the day, including the closing keynote by
mst (I did attend a talk of his) and the traditional auction.</p>

<p>I especially enjoyed...</p>

<ul>
    <li>meeting Patrick, Larry, Gloria, Aaron, Gabor and many others for the
    first time in real-life</li>
    <li>a thorough, high-bandwith discussion with Larry, Jonathan, Patrick and
    Carl about p6 spec questions, and the Perl 6 discussions mentioned
    earlier</li>
    <li>a lightning talk <em>imagine you're in a data center with no
    connection to the outside, and you accidentally executed <code>chmod -x
    chmod</code>. What would you do?</em></li>
    <li>good Italian Pizzas (although I had to wait 50 minutes for one of
    them)</li>

    <li>A talk by Tim Bunce, where he demonstrated database access in Perl 6
    both with libraries that do native calls, and through the Blizkost project
    using the Perl 5 DBI/DBD::SQLite modules</li>
    <li>the general relaxed attitude in the Perl community, where people help
    each other, and don't seem to be easily offended (at least in meat space
    :)</li>
    <li>being surrounded by many other geeks</li>
    <li>realizing that several Perl hackers brought their family to the
    conference</li>
</ul>

<p>It was an overwhelming experience, and I look forward to my next YAPC!</p>


</div>
    </content>
    <author>
      <name>Moritz Lenz</name>
    </author>
    <id>tag:perlsphere.net,2006:http://perlgeek.de/blog-en/perl-6/my-first-yapc.html</id>
  </entry>
</feed>
