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

<channel>
	<title>Perlblogs &#187; modernperl</title>
	<atom:link href="http://perlblogs.com/category/modernperl/feed/" rel="self" type="application/rss+xml" />
	<link>http://perlblogs.com</link>
	<description>Posts from selected Perl bloggers</description>
	<lastBuildDate>Mon, 06 Feb 2012 20:47:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Null Objects, Error Handling, and Robustness</title>
		<link>http://www.modernperlbooks.com/mt/2012/02/null-objects-error-handling-and-robustness.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/02/null-objects-error-handling-and-robustness.html#comments</comments>
		<pubDate>Mon, 06 Feb 2012 18:28:15 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[modernperl]]></category>
		<category><![CDATA[oo]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[softwaredesign]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=ffcf277a3ae1133a4eef67dc1c96c540</guid>
		<description><![CDATA[A Practical Use for Macros in Perl generated several thoughtful comments. While Aristotle Pagaltzis identified the real semantic difficulty with the code I wanted to write (and mentioned the Null Object pattern, which I always keep in mind), Chas. Owens...]]></description>
			<content:encoded><![CDATA[
        <p><a href="http://www.modernperlbooks.com/mt/2012/02/a-practical-use-for-macros-in-perl.html">A Practical Use for Macros in Perl</a> generated several thoughtful comments. While <a href="http://plasmasturm.org/">Aristotle Pagaltzis</a> identified the real semantic difficulty with the code I wanted to write (and mentioned the <a href="http://www.c2.com/cgi/wiki?NullObject">Null Object pattern</a>, which I always keep in mind), <a href="http://wonkden.net/">Chas. Owens</a> asked perhaps the best <em>philosophical</em> question:</p>

<blockquote><em>Why not modify add_txn to reject undefs?</em></blockquote>

<p>The code in review is:</p>

<pre><code>while (my $stock = $stock_rs-&gt;next)
{
    my $pe_update = $self-&gt;analyze_pe( $stock );
    $stock_txn-&gt;add( $pe_update ) if $pe_update;

    my $cash_yield_update = $self-&gt;analyze_cash_yield( $stock );
    $analysis_txn-&gt;add( $cash_yield_update ) if $cash_yield_update;
}</code></pre>

<p>... and the near duplication obscures (to me) the point of the code. Both Aristotle and Chas. are right&mdash;perhaps it's clearer to allow <code>$transaction-&gt;add</code> to do nothing when it receives nothing. I write "perhaps" because I see the appeal of that change, but I'm not sure I like it.</p>

<p>As usual with my software, the system has a fundamental design principle:
either succeed in full or do nothing. It's fine to skip half of the analysis
steps if the data just isn't there. (The project as a whole can succeed if it's
only 60% correct; the joy of a margin of error. It's a lot more accurate than
that.)</p>

<p>I take this principle to mean that robustness is more important than
completeness. Skipping bad data and moving on is perfectly fine. The next run
may improve transient errors, and catastrophic errors will require human
intervention anyhow.</p>

<p>When these principles translate into design, I prefer to handle errors at
the point of detection and not spread error handling throughout the system.
All of these analysis methods <em>should</em> return something. When they
succeed, they return a hash reference mapping column names to values in a
database table. When these methods fail&mdash;whether the existing data isn't
sufficient to calculate updated values or something else went wrong&mdash;they
<code>return;</code>. As you well know, that's an empty list in list context
and <code>undef</code> in the scalar context of the example code.</p>

<p>Why add nothing to a transaction when I know there's nothing to add? Yes,
<code>add()</code> could check that it has nothing to do and do nothing, and
that's fine, but it seems like that expands the behavior of
<code>add()</code>'s API to include caller errors. Then again, the
<code>add()</code> method must check that each hash reference contains a value
for the transaction's bound primary key, or it will generate buggy output.</p>

<p>I suspect that both Aristotle and Chas. have in mind <a href="http://c2.com/cgi/wiki?JonPostel">Postel's Law</a>:</p>

<blockquote><em>Be generous in what you accept and picky about what you emit.</em></blockquote>

<p>The result might look something like:</p>

<pre><code>while (my $stock = $stock_rs-&gt;next)
{
    $stock_txn-&gt;add(    $self-&gt;analyze_pe( $stock )         );
    $analysis_txn-&gt;add( $self-&gt;analyze_cash_yield( $stock ) );
}</code></pre>

<p>This change has an advantage: it only necessitates a change in the
<code>add()</code> method. All of the <code>analyze_*()</code> methods can
continue to work as implemented.</p>

<p>Of course, there's a slight performance penalty to doing this. In my case,
it's immaterial, but it wouldn't be present with macros. This is an IO-bound
application anyhow, and the transaction manager exists to avoid very real, very
measured bottlenecks.</p>

<p>Finally, Aristotle's mention of the null object pattern was about
<em>real</em> objects, and not methods which return empty lists or hash
references. If that's your style, good for you&mdash;but it's not mine in this
case. While it's not obvious from the small snippets I've posted so far, the
responsibility of the analysis methods is smaller in scope than the
responsibility of the transaction objects. Coupling transaction management to
the analysis methods&mdash;in as much that they have to know about transactions
to return the right objects&mdash;would turn the design of the system inside
out. The result would very likely not be an improvement.</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/02/06/null-objects-error-handling-and-robustness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I Run Tests on Install</title>
		<link>http://www.modernperlbooks.com/mt/2012/01/why-i-run-tests-on-install.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/01/why-i-run-tests-on-install.html#comments</comments>
		<pubDate>Tue, 31 Jan 2012 18:41:08 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[cpan]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=c3e05fd8a848a80ef83b5d3deb04579f</guid>
		<description><![CDATA[Jonathan Swartz makes a polemic statement: cpanm and perlbrew should not run tests by default. His points are reasonable, but his complaints are mostly about side effects and not the real problem. (I should clarify: the real problem I encounter.)...]]></description>
			<content:encoded><![CDATA[
        <p>Jonathan Swartz makes a polemic statement:</p>

<blockquote><em><a href="http://www.openswartz.com/2012/01/31/stop-running-tests-on-install/">cpanm and perlbrew should not run tests by default.</a></em></blockquote>

<p>His points are reasonable, but his complaints are mostly about side effects
and not the real problem. (I should clarify: the real problem <em>I</em>
encounter.)</p>

<p>If running tests slow down installs, speed up the tests. (Do you want to get the wrong answer faster? Easy: it's 42. No need for a quantum computer to do the calculation in constant time. This algorithm is O(0).)</p>

<p>If running tests exposes the fragility of the dependency chain, improve the dependency chain.</p>

<p>If dependency test failures prevent the installation of downstream
clients... this <em>is</em> a weakness of the CPAN toolchain. A well-written
test suite for a downstream client should reveal whether bugs or other sources
of test failures in a dependency affect the correctness of the client.</p>

<p>Note the assumptions in that sentence.</p>

<p>Anyone who's experienced the flash of enlightenment that comes from working
with well tested code and who's shared that new zeal with co-workers has
undoubtedly heard the hoary old truism that testing cannot prove the complete
absence of bugs. It's no less true for its age, though it's also true that
<em>good</em> testing only improves our confidence in the correctness and
efficacy of our code.</p>

<p>For me, a 95% certainty that my code works and continues to work for the
things to which I've tested it is more than sufficient. I focus on testing the
things I'm most likely to get wrong and the things which need to keep working
correctly. (I don't care much about pixel-perfect placement, but I do care that
a book's index uses the right escapes for its data and markup.)</p>

<p>Without tests running on the machines themselves in the environments
themselves where I expect my code to run, I don't have that confidence.</p>

<p>Put another way, I'm either not smart enough or far too lazy to want to
attempt to debug code without good tests. That's why I write tests, and that's
why I run them obsessively. That's good for me as a developer, and you're
getting the unvarnished developer perspective.</p>

<p><a href="http://www.modernperlbooks.com/mt/2011/10/in-search-of-minimum-viable-utility.html">I also care about the perspective of mere users</a>. (Without users, we're amusing ourselves, and I can think of better ways to amuse myself than by writing software no one uses.).</p>

<p>Yes, an excellent test suite can help a user help a developer debug a
problem. Many (most?) CPAN authors have had the wonderful experience of
receiving a bug report with a failing test case. Sometimes this even includes a
code patch.</p>

<p>Not all users are developers of that sort, nor should they be.</p>

<p>The CPAN ecosystem has improved greatly at automated testing and dependency tracking, but we can improve further. What if we could identify the severity of test failures? (We have TODO and SKIP, but they don't convey semantic meaning.) What if we could identify buggy or fragile tests? (My current favorite is <a href="https://rt.cpan.org/Ticket/Display.html?id=69540">XML::Feed tests versus DateTime::Format::Atom</a> because it catches me far too often, it doesn't affect the operation of the code, and it's a stupid fix that's lingered for a few months.) What if the failures are transient (Mechanize relying on your ISP <em>not</em> ruining DNS lookups for you) or specific to your environment (a test suite written without parallelism in mind).</p>

<p>As Jonathan rightly implies, how do you expect an end-user to understand or
care about or debug those things?</p>

<p>I'm still reluctant to agree that disabling tests for end-user installations
is the right solution. I <em>want</em> to know about failures in the wild wider
world. I want that confidence, but I can't bring myself to trade away that
confidence for the sake of a little more speed of installation.</p>

<p>Yet his point about lingering points of fragility in the ecosystem are true
and important, even if the proposed solution of skipping tests isn't right.
Fortunately, improving dependency management and tracking and use and testing
can help solve both issues: perhaps to the point where we can run only those
tests users most care about and identify and report material failures in
dependencies.</p>

        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/01/31/why-i-run-tests-on-install/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speed up Perlbrew with Test Parallelism</title>
		<link>http://www.modernperlbooks.com/mt/2012/01/speed-up-perlbrew-with-test-parallelism.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/01/speed-up-perlbrew-with-test-parallelism.html#comments</comments>
		<pubDate>Fri, 27 Jan 2012 21:20:46 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl5]]></category>
		<category><![CDATA[perlbrew]]></category>
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=cbc7696535dd728de1ef9d6b55e34b5a</guid>
		<description><![CDATA[Steven Haryanto's Perl First World Problems #1 reminded me of something I've taken for granted lately. You may have read my Controlling Test Parallelism with prove and Parallelism and Test Suites. I still have Test::Harness parallelism enabled by default on...]]></description>
			<content:encoded><![CDATA[
        <p>Steven Haryanto's <a href="http://blogs.perl.org/users/steven_haryanto/2012/01/perl-first-world-problems-1.html">Perl First World Problems #1</a> reminded me of something I've taken for granted lately.</p>

<p>You may have read my <a
href="http://www.modernperlbooks.com/mt/2011/12/controlling-test-parallelism-with-prove.html">Controlling
Test Parallelism with prove</a> and <a
href="http://www.modernperlbooks.com/mt/2011/11/parallelism-and-test-suites.html">Parallelism
and Test Suites</a>. I still have <code>Test::Harness</code> parallelism
enabled by default on most of the machines where I install my own Perls. While
I haven't yet filed tickets and tried to write patches for modules which need a
little help to run tests in parallel, I've only found a few lately that need
work. That's nice&mdash;having a module install through <code>cpanm</code> in
five seconds is a lot better than ten seconds or more. (I like
<code>cpanm</code> because it's <em>fast</em> and quiet, and part of its speed
comes from not printing to the console.)</p>

<p>I like instant feedback.</p>

<p>Like Steven, I noticed quite a while that installing a custom Perl through <a href="http://perlbrew.org/">perlbrew</a> takes a while, but then I remembered that a lot of work went into the Perl 5 test suite to make tests run in parallel. (We did something similar with Parrot several years ago, and it changed the way I work forever.)</p>

<p>To run core tests in parallel, set the environment variable
<code>TEST_JOBS=<em>n</em></code>, where <em>n</em> depends on your computer. I
use a value of 9 on a quad-core machine; in practice, that tends to keep the
CPU busy while not blocking anything too long on IO. You can set it globally in
your shell's configuration file or create an alias or wrapper for
<code>perlbrew</code>.</p>

<p>As most of the time spent compiling and installing Perl 5 through perlbrew
goes to running the test suite, this has saved me a measurable amount of
time.</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/01/27/speed-up-perlbrew-with-test-parallelism/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Decades-Old Technique to Improve Programming Languages</title>
		<link>http://www.modernperlbooks.com/mt/2012/01/a-decades-old-technique-to-improve-programming-languages.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/01/a-decades-old-technique-to-improve-programming-languages.html#comments</comments>
		<pubDate>Mon, 23 Jan 2012 20:22:23 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[languagedesign]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=444eb064a286b9c0c7a44d340e73f101</guid>
		<description><![CDATA[I promised in Testing Your Templates to explain how to solve the problem of the divergence between testable, debuggable code in your host language and a big wad of logic in a template language. This problem is an example of...]]></description>
			<content:encoded><![CDATA[
        <p>I promised in <a
href="http://www.modernperlbooks.com/mt/2012/01/testing-your-templates-and-why-it-doesnt-always-work.html">Testing
Your Templates</a> to explain how to solve the problem of the divergence
between testable, debuggable code in your host language and a big wad of logic
in a template language.</p>

<p>This problem is an example of the pattern of Why Writing Your Own DSL is
More Difficult Than You Think. Certainly Template Toolkit is among the better
templating systems (I've written a couple myself), but it exhibits problems
endemic to the process. (Then again, so does PHP. Now multiply that by the fact
that some people use templating systems <em>written in PHP</em> and if you have
to lie down for a while before the feeling passes, please accept my
apologies.)</p>

<p>The semantics of Template Toolkit are great, when they work, but then
everything's great when it works the way you expect. Robust software handles
the cases you don't expect with aplomb, or at least without a boom.</p>

<p>A simple workaround for Template Toolkit is to avoid the fallback from potential method lookup to keyed hash access when dealing with an object. In other words, if <code>$blessed_hash-&gt;do_something()</code> fails, try <code>$blessed_hash-&gt;{do_something}</code>.</p>

<p>... except that that doesn't work when you want to call virtual methods on
unblessed references, such as calling methods on arrays or hashes.</p>

<p>Another option is to change the syntax such that calling a method is visibly different from accessing a member of an aggregate. Perl 5 does this. It works pretty well, in the sense that if you use the right operator (access element versus invoke method), you've expressed your intent in a visually unambiguous fashion).</p>

<p>... except that people complain about the Perl 5 dereferencing arrow quite a
bit. (Okay, you don't <em>need</em> an arrow to do this; as the <a
href="http://onyxneon.com/books/modern_perl/index.html">Modern Perl book</a>
explains, the postfix indexed access or postfix keyed operators of
<code>{}</code> and <code>[]</code> determine the type of operation
effectively.)</p>

<p>... and except that one of the design goals of Template Toolkit was to be
robust in the face of changing values provided to the template, such that it
provides a loosely coupled interface for the data it expects. That's a fine
goal, but it isn't free.</p>

<p>Here's the thing, though. The last time I looked, Template Toolkit compiles
templates into Perl 5 code as an optimization. (The last template system I
wrote did the same thing, but not as well. We should have used TT, but in our
defense, TT didn't exist then.) This transliteration/compilation stage must be
very, very cautious to allow standard Perl debugging and introspection tools to
treat this generated code correctly. That is to say, I don't want to debug a
big wad of generated code. I want to debug the code I actually wrote.</p>

<p>As usual, the solution is another layer of abstraction.</p>

<p>Perl 5 exists in two forms. The first is the source code you and I write.
The second is the optree which the Perl 5 VM executes. There's nothing in
between. You have one or the other. When your code runs, you have the optree,
and the optree has references to the relevant location in the source code it
came from, but the correspondence is often less useful than you might like.</p>

<p>While the generated code from Template Toolkit could include the correct
file and line positions from templates, that's again less useful than you might
like. (It's useful, but it doesn't solve every problem.)</p>

<p>If Perl 5 had instead an intermediate form separate from raw code and raw
optrees, something more suitable to introspection and manipulation, we could
produce tools which worked with this intermediate form to improve debugging,
introspection, and better code generation.</p>

<p>We could even <em>inject</em> new code to add features (fall back to
attribute access; prevent the fallback to attribute access) to code, even
within lexical scopes. That is to say, we could manipulate how libraries behave
from the outside in, and ensure that our changes would not leak out from our
desired scopes.</p>

<p>It's certainly possible to replace the Perl 5 opcodes yourself, if you're
comfortable reading Perl 5 source code, writing XS, relying on black magic, and
dealing with strange issues of thread safety and manipulating global or at
least interpreter-global values in a lexical fashion (while dealing with the
fact that <code>use</code> is recursive in a sense)&mdash;but isn't Perl about
<em>not</em> making people write C to do interesting things?</p>

<p>Certainly this isn't a technique you'd use every day, and it's not obviously
a way to make Perl 5 run faster (though many optimizations become much easier),
but the possibility for better abstraction and extension and correctness has
much to recommend it.</p>

<p>And, yes, Lisp demonstrated this idea <em>ages</em> ago.</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/01/23/a-decades-old-technique-to-improve-programming-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Imagine if caller() Returned Stack-Capturing Objects</title>
		<link>http://www.modernperlbooks.com/mt/2012/01/imagine-if-caller-returned-stack-capturing-objects.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/01/imagine-if-caller-returned-stack-capturing-objects.html#comments</comments>
		<pubDate>Wed, 18 Jan 2012 22:13:36 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[features]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl5]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=47fb4f1abad1303711ce188263f3f9a5</guid>
		<description><![CDATA[Imagine if Perl 5's caller returned an object which represented the call chain to the point of the object's creation. I want to inspect the call stack within a helper module, but I don't care about the call stack within...]]></description>
			<content:encoded><![CDATA[
        <p>Imagine if Perl 5's <a
href="http://perldoc.perl.org/perlfunc.html#caller"><code>caller</code></a>
returned an object which represented the call chain to the point of the
object's creation.</p>

<p>I want to inspect the call stack within a helper module, but I don't care about the call stack <em>within</em> the module. I want to use lots of little helper functions, because that's good design, but <code>caller</code> works against that. Looking up the stack means keeping track of the magic number of call frames within my module I currently use, and that's one more thing to update when I change things.</p>

<p>That's structural code highly coupled to the arrangement of other code, and
if that doesn't wrinkle your nose with the subtle aroma of fragility and peril,
I don't know what will.</p>

<p>Imagine if instead:</p>

<pre><code>my $caller_object = capture_caller_state();

while (my $call_frame = $caller_object-&gt;next)
{
    next if $call_frame-&gt;is_eval;
    say $call_frame-&gt;location_as_string;
    my $next_frame = $call_frame-&gt;previous;
    ...
}</code></pre>

<p>Imagine if you could <em>pass this object around</em>.</p>

<p>I know things get complicated if you pass this object up the call chain, but
stack unwinding is a solved problem in that anyone capable of recognizing the
problem should be able to figure out cheap and easy ways to fix it.</p>

<p>Alas, Perl 5.14 doesn't have this feature, and it's probably too late for
5.16 to get it, so for today I'm stuck imagining what might be.</p>

<p>(If you've never thought about this sort of thing before, you owe it to yourself to learn more about <a href="http://c2.com/cgi/wiki?ContinuationPassingStyle">Continuation Passing Style</a>, which is at least an order of magnitude more mind-bending at the start and at least two orders of magnitude more useful.)</p>

        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/01/19/imagine-if-caller-returned-stack-capturing-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modern Perl 2011-2012 Edition Released!</title>
		<link>http://www.modernperlbooks.com/mt/2012/01/modernperl-2011-2012-edition-released.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/01/modernperl-2011-2012-edition-released.html#comments</comments>
		<pubDate>Thu, 12 Jan 2012 20:38:31 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl5]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=f317a73ec6312d9f4a2ff14e7f23644d</guid>
		<description><![CDATA[The Modern Perl book went to the printer earlier this week; this is the 2011-2012 edition. You can already preorder Modern Perl: 2011-2012 from Amazon and it'll be available from other bookstores in the next couple of days. I expect...]]></description>
			<content:encoded><![CDATA[
        <p>The <a href="http://onyxneon.com/books/modern_perl/index.html">Modern Perl book</a> went to the printer earlier this week; this is the 2011-2012 edition.</p>

<p>You can already <a href="http://www.amazon.com/Modern-Perl-chromatic/dp/0977920178/?tag=onyxneopre-20">preorder Modern Perl: 2011-2012 from Amazon</a> and it'll be available from other bookstores in the next couple of days. I expect copies to ship by early next week.</p>

<p>What's new?</p>

<p>I closed every bug filed against the previous edition&mdash;a handful of typos, a few confusing sections, and some suggestions on improvements. I took most of these suggestions.</p>

<p>I also revised almost every paragraph of the book, even at the sentence level. While I'm proud of the first edition, this new edition is clearer, shorter, more concise, and more accurate.</p>

<p>I removed some sections that didn't work. This didn't amount to much, but
some of the things I recommended made little sense anymore and some of the
experimental modules I mentioned turned out to be less useful than hoped. You
won't miss them. This includes a big revision of the smart matching section in
anticipation of changes in 5.16 and 5.18 (simplicity is the rule of the day;
the simpler your use of the operator, the less risk you face for confusing
behavior and edge cases).</p>

<p>I also added explanations for the new features in Perl 5.14, especially the
<code>/r</code> modifier on regular expressions, and prepared for further
features added in 5.16.</p>

<p>You might notice subtle improvements in formatting; the font size used for
code examples is larger and callouts are much more attractive. We're still
experimenting with the best way to format books to make readable text while
avoiding brick-sized tomes, so feedback is more than welcome.</p>

<p>As with the first edition, we'll make electronic versions available for free
from the Onyx Neon site. We hope to have ePub versions ready in the next two
weeks. We'll also put raw HTML online on modernperlbooks.com at the same time
(this also allows us to link to translations with greater ease). In addition,
we're making most of our publishing tools available as CPAN distributions,
including the formatting modules (<code>Pod::PseudoPod::DOM</code>) and the
rendering pipeline (<code>Pod::PseudoPod::Book</code>). This will allow you to
make your own version of the book in other languages if you desire, or to
create new and attractive books in many formats. We'll make our own Kindle
version, rather than using Amazon's conversion tools (they didn't work as well
as we'd hoped), and we hope to get the book in the Nook store as well.</p>

<p>We plan to release a new version of the book late this year or early next
year to cover 5.14 and 5.16. We'll almost certainly drop support and mention of
5.10.</p>

<p>We couldn't have done this book without you. Thanks for reading. Please
share with your friends.</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/01/12/modern-perl-2011-2012-edition-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Little Bit is A Lot Better</title>
		<link>http://www.modernperlbooks.com/mt/2012/01/a-little-bit-is-a-lot-better.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/01/a-little-bit-is-a-lot-better.html#comments</comments>
		<pubDate>Mon, 09 Jan 2012 19:48:51 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[cpan]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=4df8a55681ff0ae28421e912d885fdee</guid>
		<description><![CDATA[Buddy Burden explanation of taking over maintenance of CPAN distributions is important. It's empowering. If you've ever thought &#34;I should contribute something to Perl&#34;, start there. You can do it. Sure, it's easy for me to say that. I've written...]]></description>
			<content:encoded><![CDATA[
        <p><a href="http://blogs.perl.org/mt/mt-cp.fcgi?__mode=view&id=1580">Buddy Burden</a> explanation of <a href="http://blogs.perl.org/users/buddy_burden/2012/01/stepping-up.html">taking over maintenance of CPAN distributions</a> is important. It's empowering. If you've ever thought "I should contribute something to Perl", start there.</p>

<p>You can do it.</p>

<p>Sure, it's easy for <em>me</em> to say that. I've written a few things about
Perl a few people have read. I have a few patches in a few projects and a
couple of modules on the CPAN myself. (You're reading this, aren't you? So I
have at least one reader. Thank you for your time!)</p>

<p>Even with all that in mind, two questions still come up far too often, and I think they prevent or delay us from providing code and documentation for other people to use freely:</p>

<ul>

<li>Does anyone care?</li>

<li>Is it good enough (yet)?</li>

</ul>

<p>You can see this attitude in the recurring debate over the responsibilities of authors. While some people say it's irresponsible or childish or unprofessional to upload code without full test coverage or complete documentation or an iron-clad promise to respond to every bug within 24 hours with a fix, an apology, a new release, and a sandwich (and yes, I exaggerate for effect), we're doing each other a disservice setting these demands on ourselves and each other.</p>

<p><em>Yes</em>, we should do our best.</p>

<p>... but <em>yes</em>, we can start from something small and incomplete and
refine it in smaller steps. It doesn't have to pass every test on every
platform known to man if you can get feedback on where it fails and release a
new version tomorrow. It doesn't have to have every feature you plan to add, if
it does something useful that other people might want to use today. It doesn't
have to have every option documented if it's usable right now.</p>

<p>I'm not suggesting that we allow ourselves to be irresponsible with what we
share, but I am suggesting that we can allow ourselves the freedom to share a
little earlier and a little more often. We have the ability to upload new code
every day (every hour!) if we want.</p>

<p>So what if it's not perfect? Even if you waited until you thought you'd achieved perfect, you probably would miss, even by a little bit.</p>

<p>Start small. Do your research&mdash;work to your best quality&mdash;but let yourself hit smaller goals and make things a little bit better a little more often. Share earlier. This is a lot better for everyone.</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/01/09/a-little-bit-is-a-lot-better/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modern::Perl Updates</title>
		<link>http://www.modernperlbooks.com/mt/2012/01/modernperl-updates.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/01/modernperl-updates.html#comments</comments>
		<pubDate>Thu, 05 Jan 2012 20:34:04 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[perl5]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=e111c8530c409abb316f409fa5f73041</guid>
		<description><![CDATA[The Modern::Perl CPAN distribution is much more conservative than I think most people thought it would be when I first released it. (Count me in that group.) Where I once intended to collect a bunch of useful CPAN modules in...]]></description>
			<content:encoded><![CDATA[
        <p>The <a href="http://search.cpan.org/perldoc?Modern::Perl">Modern::Perl</a> CPAN distribution is much more conservative than I think most people thought it would be when I first released it. (Count me in that group.) Where I once intended to collect a bunch of useful CPAN modules in the style of <a href="http://search.cpan.org/perldoc?Task::Kensho">Task::Kensho</a> or <a href="http://search.cpan.org/perldoc?perl5i">perl5i</a>, both of those do what they do far better than I can do.</p>

<p>Instead, I see Modern::Perl as enabling the core features I wish were on out
of the box by default in Perl 5. While it'd be nice to pull in <a
href="http://search.cpan.org/perldoc?Try::Tiny">Try::Tiny</a> and sometimes I
might wish for fatal warnings, the former is not a core module and the second
isn't something I use in every program.</p>

<p>Consequently the module hasn't needed much maintenance. Yet I've added a couple of missing features that should keep it useful and usable into the
future. I uploaded a new version yesterday and will upload one more today with a little bit more polish.</p>

<p>First, it now requires <a
href="http://search.cpan.org/perldoc?autodie">autodie</a> as a distribution
dependency. It doesn't <em>load</em> <code>autodie</code>, but installing
Modern::Perl on 5.10.0 will also install <code>autodie</code>. (Anything 5.10.1
and newer includes <code>autodie</code> in the core.) You don't have to use it,
but now you can rely on any Perl considered modern to have <code>autodie</code>
available.</p>

<p>Second, it now loads <a
href="http://search.cpan.org/perldoc?IO::File">IO::File</a> and <a
href="http://search.cpan.org/perldoc?IO::Handle">IO::Handle</a> so that you can
call methods on lexical filehandles without having to load either manually.
Perl 5.14 fixed that usability niggle, but Modern::Perl fixes this for people
using 5.10 or 5.12. (Why both? I can never remember which one superseded the
other in 5.12, but better safe than sorry. I welcome a patch to load one over
the other with a version check&mdash;and please test carefully.)</p>

<p>Third, I added unimporting support so that you can write <code>no
Modern::Perl;</code> within a scope to disable strictures, warnings, and
language bundle features. It's an all or nothing switch and will remain that
way, but I can see this being useful in specific cases, especially when
updating older code in stages.</p>

<p>Finally I added date support to importing. If you write <code>use
Modern::Perl;</code> you'll get the features of Perl 5.10 (with the caveat that
if you're using Perl 5.11.3 or newer, you also get the
<code>unicode_strings</code> feature, of which all you're likely to notice is
that Unicode strings work better in more places).</p>

<p>Yet for forward compatibility, you should be using:</p>

<pre><code>use Modern::Perl 2012;</code></pre>

<p>... which enables 5.14 features. You can use 2009 and 2010 to get 5.10
features and 2011 to get 5.12 features. If you use the wrong date on the wrong
version of Perl 5, you'll get an error, which is as it should be.</p>

<p>Next year I'm likely to drop support for Perl 5.10, in which case you'll
probably get an error message that that year isn't modern enough, but I could
be convinced to do a version check instead. I haven't decided. The tradeoff is
between providing a minimal module suitable for use in programs which helps
people write better code from the start and between telling people what they
should and shouldn't use. Besides all that, the relevant code is only a couple of dozen lines of very simple Perl. Anyone reading this can reimplement it almost trivially.</p>

<p>Of course, this all comes about because the <a
href="http://onyxneon.com/books/modern_perl/index.html">Modern Perl book</a>
goes to the printer today. We're very proud of the new 2011-2012 edition which
concentrates on Perl 5.12 and Perl 5.14. It addresses all of the known typos
and confusing parts of the previous edition, covers new features in Perl 5.14,
and is, from all reports, even better than the first edition.</p>

<p>The book should be in stores in the next week or so, and we'll have
electronic editions up this month for free download and redistribution. (We
hope you tell lots of people to buy the print edition because it's great and
more people need it on their desks, but sharing is caring and we support
that.)</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/01/05/modernperl-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do It Wrong Sometimes</title>
		<link>http://www.modernperlbooks.com/mt/2012/01/do-it-wrong-sometimes.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/01/do-it-wrong-sometimes.html#comments</comments>
		<pubDate>Tue, 03 Jan 2012 22:14:17 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[cpan]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[skunkworks]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=0b504cc8284bd3b38992db8dc0ebfd6f</guid>
		<description><![CDATA[The YAPC::NA 2012 call for presentations has opened! As with every YAPC I've attended, this is a great opportunity to meet other programmers, learn things you know better and don't know yet, and to practice your presentation skills. A few...]]></description>
			<content:encoded><![CDATA[
        <p>The <a href="http://act.yapcna.org/2012/">YAPC::NA 2012</a> call for presentations has opened! As with every YAPC I've attended, this is a great opportunity to meet other programmers, learn things you know better and don't know yet, and to practice your presentation skills.</p>

<p>A few months ago I exchanged emails with <a href="http://www.plainblack.com/">JT Smith</a> about my idea for a talk this year. I've mentioned in passing a few times <a href="http://www.modernperlbooks.com/mt/2011/08/why-my-side-project-doesnt-use-perl-6.html">a small side project my business is investing in</a>. It's a side project, deliberately minimal, and&mdash;from the development side&mdash;definitely the kind of skunkworks, just get it working, maintain it as little as possible and let it run uninterrupted software that you're likely to find.</p>

<p>That doesn't mean it's quick or dirty. That doesn't mean it's not tested well, or that it has a slapdash design. All it means is that the most important criterion for any design or implementation decision is "is this the simplest thing that could possibly work" instead of "is this elegant" or "what's the standard modern Perl orthodoxy for this problem".</p>

<p>So far the results have been enlightening.</p>

<p>I don't want to give away too many of the details of my talk (if it's accepted), but here are two small hints which may or may not help you.</p>

<p>First, just because a good ORM such as <a href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a> makes searching and manipulating existing data easy doesn't make it the best way to insert big batches of new data.</p>

<p>Second, while <a href="http://search.cpan.org/perldoc?LWP">LWP</a> and especially <a href="http://search.cpan.org/perldoc?WWW::Mechanize">WWW::Mechanize</a> are great tools for automating the behavior of a web client, sometimes <code>wget</code> or <code>curl</code> in a shell script is quicker, easier to parallelize, and more robust.</p>

<p>(As a bonus, consider also that if you're parsing semi-structured data out of HTML that removing <em>all</em> of the HTML is sometimes even easier than using a real HTML parser or even CSS selectors. Sure, semantic markup helps when you can rely on it, and sure, using a regex to remove HTML tags is a bad idea, but there are ways to turn HTML into plain text quickly and easily without doing anything on your own.)</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/01/04/do-it-wrong-sometimes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Would You Track User Behavior with Plack and Catalyst?</title>
		<link>http://www.modernperlbooks.com/mt/2011/12/how-would-you-track-user-behavior-with-plack-and-catalyst.html</link>
		<comments>http://www.modernperlbooks.com/mt/2011/12/how-would-you-track-user-behavior-with-plack-and-catalyst.html#comments</comments>
		<pubDate>Mon, 19 Dec 2011 21:41:44 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[catalyst]]></category>
		<category><![CDATA[metrics]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl5]]></category>
		<category><![CDATA[plack]]></category>
		<category><![CDATA[webprogramming]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=e64ae5b969a76f8b0fd4763a0b554159</guid>
		<description><![CDATA[One of the persistent questions which keeps entrepreneurs on the edge is &#34;Are we building the right thing?&#34; In the first web bubble, the Silly side of Silicon Valley chased vanity metrics such as &#34;the number of eyeballs on the...]]></description>
			<content:encoded><![CDATA[
        <p>One of the persistent questions which keeps entrepreneurs on the edge is
"Are we building the right thing?"</p>

<p>In the first web bubble, the Silly side of Silicon Valley chased vanity
metrics such as "the number of eyeballs on the site" and "brand awareness" and
"unique visitors". Those numbers are only interesting when you can correlate
them to producing value for customers and bringing in real cash in the form of
revenue.</p>

<p>I've enjoyed the book <a
href="http://www.amazon.com/Lean-Startup-Entrepreneurs-Continuous-Innovation/dp/0307887898?tag=onyneopre-20">The
Lean Startup</a> by Eric Ries because he offers a much better mechanism to
track the success or failure of any attempt to produce real value to customers.
While split testing (or A/B testing) is useful to see how small changes lead to
different customer behaviors, Ries recommends <a
href="http://www.avc.com/a_vc/2009/10/the-cohort-analysis.html">cohort
analysis</a>, where you can see the behavior of real customers through the <a
href="http://www.mindtools.com/pages/article/newLDR_94.htm">sales funnel</a>
and correlate the X-axis with individual changes to your business or
product.</p>

<p>That means tracking customer behavior. If you're building some sort of
software as a service product, and if the mechanism of delivery of that product
is primarily a web site, you probably already know the punchline.</p>

<p>Assume I already know how to identify and log events for each salient
customer action type. (I've built that kind of system before.) Assume I don't
want to collect personally identifiable information (I don't). Assume I'm using
<a href="http://plackperl.org/">Plack</a> and its middleware heavily, and
assume I'm happy using <a href="http://catalystframework.org/">Catalyst</a> as
a web framework.</p>

<p>How can I identify unique users (with and without accounts) on a daily
basis, anonymize them, but group their actions across the site such that my
automated daily cohort graphs correspond with reality?</p>

<p>So far I've identified few points of possible contention. I can rely on
browser cookies for unique identification of users if I <em>know</em> that user
sessions have unique identifiers within a 24 hour period. (I could generate
GUIDs for this, but that may be overdoing things.) I <em>think<</em> I also
have to track the transition from anonymous visitor to authenticated user, but
I might be able to convince myself that either replacing the current session or
smple subtraction of successful login events from total number of unique
anonymous visitors would give the right numbers.</p>

<p>(I also haven't dived much into how Catalyst 5.9 and Plack interact in terms
of session and cookie handling. Everything's just worked, so I've ignored the
details until now.)</p>

<p>I don't mind building such a system if necessary, but if all of the pieces
are out there and available&mdash;or if someone's already built this and can
give guidance&mdash;so much the better.</p>

<p>Have you solved this problem? If so, how did you do it? If not, how would
you do it? Would you handle logging at the Plack level or the application
level? Would you worry about tracking session changes? Does Catalyst need to
know about this?</p>

        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2011/12/19/how-would-you-track-user-behavior-with-plack-and-catalyst/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

