<?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; cpan</title>
	<atom:link href="http://perlblogs.com/category/cpan/feed/" rel="self" type="application/rss+xml" />
	<link>http://perlblogs.com</link>
	<description>Posts from selected Perl bloggers</description>
	<lastBuildDate>Fri, 18 May 2012 19:03:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Perlbuzz news roundup for 2012-05-14</title>
		<link>http://feedproxy.google.com/~r/PerlBuzz/~3/9yfCnPNae8Q/perlbuzz-news-roundup-for-2012-05-14.html</link>
		<comments>http://feedproxy.google.com/~r/PerlBuzz/~3/9yfCnPNae8Q/perlbuzz-news-roundup-for-2012-05-14.html#comments</comments>
		<pubDate>Mon, 14 May 2012 19:20:11 +0000</pubDate>
		<dc:creator>Andy Lester</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=bac1182143c5db6e52490336c3f09591</guid>
		<description><![CDATA[These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com. YAPC::NA will be livestreamed in real-time for free (blog.yapcna.org) Introduction to how to do Perl one-liners (catonmat.net) NYTProf,...]]></description>
			<content:encoded><![CDATA[
        <p>
These links are collected from the
<a href="http://twitter.com/perlbuzz">Perlbuzz Twitter feed</a>.
If you have suggestions for news bits, please mail me at
<a href="mailto:andy@perlbuzz.com">andy@perlbuzz.com</a>.
</p>

<ul>

<li>YAPC::NA will be livestreamed in real-time for free (<a href="http://blog.yapcna.org/post/22588737837/yapc-na-will-be-televised">blog.yapcna.org</a>)</li>
<li>Introduction to how to do Perl one-liners (<a href="http://www.catonmat.net/blog/introduction-to-perl-one-liners/">catonmat.net</a>)</li>
<li>NYTProf, File IO, and an Optimization Gone Awry (<a href="http://www.modernperlbooks.com/mt/2012/05/nytprof-file-io-and-an-optimization-gone-awry.html">modernperlbooks.com</a>)</li>
<li>Reddit API for Perl (<a href="http://blogs.perl.org/users/jeff_ober/2012/05/reddit-api-for-perl.html">blogs.perl.org</a>)</li>
<li>Lots of Perl authors at YAPC::NA this year (<a href="http://blog.yapcna.org/post/22717040291/lots-of-perl-authors">blog.yapcna.org</a>)</li>
<li>Review of "Programming Perl, 4th ed." (<a href="http://i-programmer.info/bookreviews/116-perl/4189-programming-perl.html">i-programmer.info</a>)</li>
<li>Don't use Cache::Memcached for UTF8 strings (<a href="http://domm.plix.at/perl/2012_05_10_dont_use_cache_memcached_for_utf8_strings.html">domm.plix.at</a>)</li>
<li>PerlGSL, interfaces to the GNU Scientific Library (<a href="http://blogs.perl.org/users/joel_berger/2012/05/announcing-perlgsl---a-collection-of-perlish-interfaces-to-the-gnu-scientific-library.html">blogs.perl.org</a>)</li>
<li>Learning Perl with testing (<a href="http://nbezzala.blogspot.com/2012/04/learning-perl-with-testing.html">nbezzala.blogspot.com</a>)</li>
<li>Separating presentation and content in TT (<a href="http://www.modernperlbooks.com/mt/2012/05/separating-presentation-from-content-in-templates.html">modernperlbooks.com</a>)</li>
</ul>

        
    <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=9yfCnPNae8Q:-WfIU6fGL0o:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=9yfCnPNae8Q:-WfIU6fGL0o:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=9yfCnPNae8Q:-WfIU6fGL0o:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=9yfCnPNae8Q:-WfIU6fGL0o:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=9yfCnPNae8Q:-WfIU6fGL0o:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=9yfCnPNae8Q:-WfIU6fGL0o:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PerlBuzz/~4/9yfCnPNae8Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/05/14/perlbuzz-news-roundup-for-2012-05-14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Attribute-Based Template Exporting</title>
		<link>http://www.modernperlbooks.com/mt/2012/05/simple-attribute-based-template-exporting.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/05/simple-attribute-based-template-exporting.html#comments</comments>
		<pubDate>Fri, 11 May 2012 20:29:01 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[cpan]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[webprogramming]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=8072073cb45a2548172a881d305c3f74</guid>
		<description><![CDATA[If you're like me and your design skills are sufficient to modify something decent to look nice but insufficient to create something from first principles, you can do a lot worse than to play with Twitter Bootstrap for your next...]]></description>
			<content:encoded><![CDATA[
        <p>If you're like me and your design skills are sufficient to modify something
decent to look nice but insufficient to create something from first principles,
you can do a lot worse than to play with <a
href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a> for your next
web site.</p>

<p>I've used it successfully for a few projects and it's been great.</p>

<p>It's a lot better now that I've written my own silly little <a
href="http://template-toolkit.org/">Template Toolkit</a> plugin to reduce the
need for writing lots of repetitive HTML in my templates. (It's like <a
href="http://haml-lang.com/">Haml</a> but less ugly and more Perlish and easier
to extend.)</p>

<p>Writing a TT2 plugin is relatively easy. Of course I do it the wrong way;
when you initialize your plugin, you have the ability to manipulate TT2's
stash. This is the data structure representing the variables in scope in your
templates. Where a well-behaved template should use object methods to perform
its operations, my code stuffs function references in the stash. Here's the
relevant code:</p>

<pre><code>sub new
{
    my ($class, $context, @params) = @_;

    $class-&gt;add_functions( $context );

    return $class-&gt;SUPER::new( $context, @params );
}

sub add_functions
{
    my ($class, $context) = @_;
    my $stash             = $context-&gt;stash;

    while (my ($name, $ref) = each %exports)
    {
        $stash-&gt;set( $name, $ref );
    }

    $stash-&gt;set( process =&gt; sub { $context-&gt;process( @_ ) } );
}</code></pre>

<p>I'll fix this eventually, but the process of making this work was
interesting.</p>

<p>In my first attempt (see <a
href="http://www.modernperlbooks.com/mt/2012/05/write-the-wrong-code-first.html">Write
the Wrong Code First</a> for the justification), I'd write the function I
needed, like <code>row()</code>, which creates a new Bootstrap row or
<code>maincontent()</code> which creates the main content area of the page.
Then I'd add that function to the <code>%exports</code> hash and everything
would work.</p>

<p>After the sixth function, keeping that list up to date was tedious. Then I
kept forgetting it. After all, any time you have to update the same data in two
places, you're doing something wrong.</p>

<p>Now the code looks more like:</p>

<pre><code>sub row <strong>:Export</strong>
{
    return &lt;&lt;END_HTML;
&lt;div class="row"&gt;
    @_
&lt;/div&gt;
END_HTML
}</code></pre>

<p>... with a single code attribute marking those functions which I want to
stuff into the template stash. I've used <a
href="http://search.cpan.org/perldoc?Attribute::Handlers">Attribute::Handlers</a>
before, but I always end up reading the manual and playing with things to get
them to work correctly. (Something about the way you have to write another
package and inherit from it to get your attributes to work correctly always
confuses me.)</p>

<p>My second attempt lasted no longer than ten minutes. I switched to <a href="http://search.cpan.org/perldoc?Attribute::Lexical">Attribute::Lexical</a>. This is almost as trivial to use as to explain:</p>

<pre><code>use Attribute::Lexical 'CODE:Export' => \&amp;export_code;</code></pre>

<p>Whenever any function has the <code>:Export</code> attribute, Perl wil lcall
my <code>export_code()</code> function:</p>

<pre><code>my %exports;

sub export_code
{
    my $referent = shift;
    my $name     = Sub::Identify::sub_name( $referent );

    return unless $name;
    $exports{$name} = $referent;
}</code></pre>

<p>The first argument to this function is a reference to the exported function.
I use <a href="http://search.cpan.org/perldoc?Sub::Identify">Sub::Identify</a>
to get the name of the function reference. (That wouldn't work for anonymous
functions, but I can control that here.) Then I store the name of the function
and the function reference in a hash.</p>

<p>It took as long to write as it does to explain.</p>

<p>A lot of people dislike the use of attributes. Used poorly, they create
weird couplings and plenty of action at a distance.
<code>Attribute::Handlers</code> can be confusing.</p>

<p>I like to think that I'm using attributes well here (even if I'm abusing TT2
more than a little), and that they've simplified my code so that I can avoid
repeating myself and performing manual busywork that I'm likely to forget. Even
better, the code to use them isn't magical at all: it's all hidden behind the
pleasant interfaces of <code>Attribute::Lexical</code> and
<code>Sub::Identify</code>.</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/05/11/simple-attribute-based-template-exporting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NYTProf, File IO, and an Optimization Gone Awry</title>
		<link>http://www.modernperlbooks.com/mt/2012/05/nytprof-file-io-and-an-optimization-gone-awry.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/05/nytprof-file-io-and-an-optimization-gone-awry.html#comments</comments>
		<pubDate>Mon, 07 May 2012 21:56:41 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[cpan]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[softwaredevelopment]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=ce8793e9ef2fc7b17ac9464159a79cc7</guid>
		<description><![CDATA[One of my projects performs a lot of web scraping. Once every n units of time (where n can be days or weeks), a batch process fetches several web pages and extracts information from them. It's a problem solved very...]]></description>
			<content:encoded><![CDATA[
        <p>One of my projects performs a lot of web scraping. Once every <em>n</em>
units of time (where <em>n</em> can be days or weeks), a batch process fetches
several web pages and extracts information from them. It's a problem solved
very well.</p>

<p>I designed this system around the idea of a pipeline of related processes,
where each component is as independent and idempotent as possible. This has
positives and negatives; it's an abstraction like any other.</p>

<p>I initially wrote the "fetch remote web page" and "analyze data from that
page" as a single step, because I thought "analyze" was the main goal and
"fetch" was a dependent task. I separated them a couple of weeks ago to
simplify the system: analysis now expects data to be there, while fetching can
be parallel on a single or across multiple machines. (Testing the analysis step
is also much easier because feeding in dummy data is now trivial.)</p>

<p>I use the filesystem as a cache for these fetched files. That's easy to
manage. I modified the role I use to grab data for the analysis stage to look
in the cache first, then fall back to a network request. That was easy too. The
<code>get_formatted_data_for_analysis()</code> method looked something like:<p>

<pre><code>sub get_formatted_data_for_analysis
{
    my ($self, $type, $key) = @_;

    my $cached_path         = $self-&gt;get_cached_path( $type, $key );
    if (-e $cached_path)
    {
        my $text = read_file( $cached_path );
        return $self-&gt;formatter-&gt;format_string( $text ) if $text;
    }

    return $self-&gt;formatter-&gt;format_string( $self-&gt;fetch_by_url( $type, $key ) );
}</code></pre>

<p>I thought I was done. This trivial caching layer took five minutes to write and gave my project a lot of flexibility.</p>

<p>I thought this would speed up the processing stage, because I was able to
make the fetching stage embarrassingly parallel so that more than one fetch
could block on network IO simultaneously. My rough benchmark didn't show any
speed improvement, but it was fast enough, so I moved on.</p>

<p>On Friday I decided to profile the slowest stage of the application with <a
href="http://search.cpan.org/perldoc?Devel::NYTProf">Devel::NYTProf</a>. The
slowest stage was the processing stage. I isolated it so that it performed no
network fetching. It was still slow.</p>

<p>One of the formatter modules used to extract data from web pages is <a
href="http://search.cpan.org/perldoc?HTML::FormatText::Lynx">HTML::FormatText::Lynx</a>.
It allows me to run <code>lynx --dump</code> to strip out all of the HTML and
other formatting of a document. The formatter allows you to pass in the name of
a file or the contents of a file as a string.</p>

<p>For some reason, most of the time in the processing stage in the profile was
spent in file IO. That wasn't too surprising; these aren't all small files and
there may be thousands of them. I dug deeper.</p>

<p>Most of the time in the processing stage in the profile was spent in reading
the files in my method and reading files in the formatter&mdash;reading files,
even though I was passing the contents of those files to the formatter as
strings.</p>

<p>I poked around at a few other things, but came back to the source code of
the formatter. A comment in <a
href="http://search.cpan.org/perldoc?HTML::FormatExternal">HTML::FormatExternal</a>
says:

<blockquote><code>format_string()</code> takes the easy approach of putting the
string in a temp file and letting <code>format_file()</code> do the real work.
The formatter programs can generally read stdin and write stdout, so could do
that with <code>select()</code> to simultaneously write and read
back.</blockquote>

<p>In other words, all of the work I was doing to read in files was busy work,
duplicating what the formatter was about to do anyway. (Okay, I stared at the
code for a couple of minutes, thinking about various approaches of rewriting it
and submitting a patch or monkey patching it. Then I turned lazier and wiser.)
I rewrote my code:</p>

<pre><code>sub get_formatted_data_for_analysis
{
    my ($self, $type, $key) = @_;

    my $cached_path         = $self-&gt;get_cached_path( $type, $key );
    return $self-&gt;formatter-&gt;format_file( $cached_path ) if -e $cached_path;

    return $self-&gt;formatter-&gt;format_text( $self-&gt;fetch_by_url( $type, $key ) );
}</code></pre>

<p>The result was a 25% performance improvement.</p>

<p>Three things jumped out at me in this process. First, how nice is it to have
a working tool like NYTProf and a community that distributes source code, so
that I could examine the whole stack of my application to isolate performance
problems? Second, how interesting that an assumption and an admitted shortcut
in a dependency could have such an effect on my own code. Third, how much more
I like my new code with all of the file handling gone; pushing that
responsibility elsewhere is a nice simplification without the performance
improvement.</p>

<p>Perhaps the two tools I miss most from my C programming days are
Valgrind/Callgrind and KCachegrind, but NYTProf goes a long way toward filling
that gap. Besides, I'm at least 20 times more productive with a language like
Perl.</p>

        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/05/07/nytprof-file-io-and-an-optimization-gone-awry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perlbuzz news roundup for 2012-05-07</title>
		<link>http://feedproxy.google.com/~r/PerlBuzz/~3/o9hwMDipS2Y/perlbuzz-news-roundup-for-2012-05-07.html</link>
		<comments>http://feedproxy.google.com/~r/PerlBuzz/~3/o9hwMDipS2Y/perlbuzz-news-roundup-for-2012-05-07.html#comments</comments>
		<pubDate>Mon, 07 May 2012 14:26:45 +0000</pubDate>
		<dc:creator>Andy Lester</dc:creator>
				<category><![CDATA[cpan]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=d4e6f45e180c8a72b23bd749b89b61c3</guid>
		<description><![CDATA[These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com. Always encode and decode Unicode at the edges of your program (perl.com) mod_perl 2.0.6 released (blogs.perl.org) Comments are...]]></description>
			<content:encoded><![CDATA[
        <p>
These links are collected from the
<a href="http://twitter.com/perlbuzz">Perlbuzz Twitter feed</a>.
If you have suggestions for news bits, please mail me at
<a href="mailto:andy@perlbuzz.com">andy@perlbuzz.com</a>.
</p>

<ul>

<li>Always encode and decode Unicode at the edges of your program (<a href="http://www.perl.com/pub/2012/05/perlunicook-make-file-io-default-to-utf-8.html">perl.com</a>)</li>
<li>mod_perl 2.0.6 released (<a href="http://blogs.perl.org/users/phred/2012/05/mod-perl-206-released.html">blogs.perl.org</a>)</li>
<li>Comments are open on the Perl Foundation's latest grant proposals (<a href="http://news.perlfoundation.org/2012/05/2012q2-grant-proposals.html">news.perlfoundation.org</a>)</li>
<li>Creating weekly schedule charts with HTML::Template (<a href="http://blog.nu42.com/2012/05/generate-pretty-weekly-schedule-chart.html">blog.nu42.com</a>)</li>
<li>Playing music with Audio::Beep (<a href="http://blog.und3f.com/joy-of-the-internal-speaker">blog.und3f.com</a>)</li>
<li>Tad McClellan has passed away (<a href="http://blogs.perl.org/users/brian_d_foy/2012/05/tad-mcclellan-rip.html">blogs.perl.org</a>)</li>
<li>Coding before having expert-level understanding is OK (<a href="http://www.modernperlbooks.com/mt/2012/05/smoothing-the-condescending-onramp.html">modernperlbooks.com</a>)</li>
</ul>

        
    <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=o9hwMDipS2Y:Ogho2fJNLTE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=o9hwMDipS2Y:Ogho2fJNLTE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=o9hwMDipS2Y:Ogho2fJNLTE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=o9hwMDipS2Y:Ogho2fJNLTE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=o9hwMDipS2Y:Ogho2fJNLTE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=o9hwMDipS2Y:Ogho2fJNLTE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PerlBuzz/~4/o9hwMDipS2Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/05/07/perlbuzz-news-roundup-for-2012-05-07/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perlbuzz news roundup for 2012-04-30</title>
		<link>http://feedproxy.google.com/~r/PerlBuzz/~3/CXEmEdPn3VQ/perlbuzz-news-roundup-for-2012-04-30.html</link>
		<comments>http://feedproxy.google.com/~r/PerlBuzz/~3/CXEmEdPn3VQ/perlbuzz-news-roundup-for-2012-04-30.html#comments</comments>
		<pubDate>Mon, 30 Apr 2012 17:45:56 +0000</pubDate>
		<dc:creator>Andy Lester</dc:creator>
				<category><![CDATA[Code craft]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=80afc4eebb7d779de6f4953c0c9ff1fa</guid>
		<description><![CDATA[These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com. In case you have a burning need to use ಠ_ಠ for warnings/errors: (metacpan.org) Expanded the &#34;More Tools&#34; page...]]></description>
			<content:encoded><![CDATA[
        <p>
These links are collected from the
<a href="http://twitter.com/perlbuzz">Perlbuzz Twitter feed</a>.
If you have suggestions for news bits, please mail me at
<a href="mailto:andy@perlbuzz.com">andy@perlbuzz.com</a>.
</p>

<ul>

<li>In case you have a burning need to use ಠ_ಠ for warnings/errors: (<a href="https://metacpan.org/module/Acme%3A%3AEmoticarp">metacpan.org</a>)</li>
<li>Expanded the "More Tools" page of the ack website: (<a href="http://betterthangrep.com/more-tools/">betterthangrep.com</a>) Help your users by including alternatives for them to choose from!</li>
<li>YAPC::NA is NOT sold out. Still 30 tickets left. Sign up now! (<a href="http://blog.yapcna.org/post/21738186538/yapc-na-not-sold-out-after-all">blog.yapcna.org</a>)</li>
<li>Before you send a patch, send an email (<a href="http://petdance.com/2012/04/before-you-write-a-patch-write-an-email/">petdance.com</a>)</li>
<li>For want of a newline (<a href="http://blogs.perl.org/users/sirhc/2012/04/for-want-of-a-newline.html">blogs.perl.org</a>)</li>
<li>Use the command "perldoc -q whatever" to search the Perl FAQ for "whatever"</li>
<li>Perl 5.16.0 is coming soon, probably early May (<a href="http://rjbs.manxome.org/rubric/entry/1955">rjbs.manxome.org</a>)</li>
<li>Regexp::Common has regexes for just about everything. Check there first. (<a href="http://search.cpan.org/dist/Regexp-Common/">search.cpan.org</a>)</li>
<li>Is Try::Tiny still the best choice for exception handling? (<a href="http://stackoverflow.com/questions/10364975/">stackoverflow.com</a>)</li>
<li>Using named regexes in ack output (<a href="http://stackoverflow.com/questions/4222727/how-to-use-named-regex-groups-in-ack-output">stackoverflow.com</a>)</li>
<li>Automating gov't websites w/WWW::Mechanize + HTML::DOM (<a href="http://blogs.perl.org/users/sirhc/2012/04/automating-on-call-jury-instructions.html">blogs.perl.org</a>)</li>
<li>Using Moose's "lazy" attribute for caching (<a href="http://blogs.perl.org/users/buddy_burden/2012/04/lazy-cache.html">blogs.perl.org</a>)</li>
</ul>

        
    <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=CXEmEdPn3VQ:D_gVJn07tbk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=CXEmEdPn3VQ:D_gVJn07tbk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=CXEmEdPn3VQ:D_gVJn07tbk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=CXEmEdPn3VQ:D_gVJn07tbk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=CXEmEdPn3VQ:D_gVJn07tbk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=CXEmEdPn3VQ:D_gVJn07tbk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PerlBuzz/~4/CXEmEdPn3VQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/04/30/perlbuzz-news-roundup-for-2012-04-30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make a DBIC Schema from DDL</title>
		<link>http://www.modernperlbooks.com/mt/2012/04/make-a-dbic-schema-from-ddl.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/04/make-a-dbic-schema-from-ddl.html#comments</comments>
		<pubDate>Fri, 27 Apr 2012 20:05:45 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[cpan]]></category>
		<category><![CDATA[dbixclass]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=89dba20bb9817607a15c78b55adb195f</guid>
		<description><![CDATA[For some reason, creating DBIx::Class schemas by hand has never made sense to me. I like to write my CREATE TABLE statements instead. DBIx::Class::Schema::Loader works really well for this. I keep this schema DDL in version control. I also keep...]]></description>
			<content:encoded><![CDATA[
        <p>For some reason, creating <a
href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a> schemas by
hand has never made sense to me. I like to write my <code>CREATE TABLE</code>
statements instead. <a
href="http://search.cpan.org/perldoc?DBIx::Class::Schema::Loader">DBIx::Class::Schema::Loader</a>
works really well for this.</p>

<p>I keep this schema DDL in version control. I also keep a SQLite database
around with some test data (but the database isn't in version control).</p>

<p>I usually find myself writing a little shell script or other program to to
regenerate the DBIC schema from that test database. That usually requires me to
make manual changes to the test database representing the changes I've just
made to the DDL.</p>

<p>After doing this one too many times, I decided to combine <a
href="http://search.cpan.org/perldoc?DBIx::RunSQL">DBIx::RunSQL</a> with the
schema loader. By creating a SQLite database from my DDL <em>in memory</em>, I
can create a schema without me modifying any databases manually.</p>

<p>This was easier than I thought:</p>

<pre><code>#!/usr/bin/env perl

use Modern::Perl;

use DBIx::RunSQL;
use DBIx::Class::Schema::Loader 'make_schema_at';

my $test_dbh = DBIx::RunSQL-&gt;create(
    dsn     =&gt; 'dbi:SQLite:dbname=:memory:',
    sql     =&gt; 'db/schema.sql',
    force   =&gt; 1,
    verbose =&gt; 1,
);

make_schema_at( 'MyApp::Schema',
    {
        components =&gt; [ 'InflateColumn::DateTime', 'TimeStamp' ],
        debug =&gt; 1,
        dump_directory =&gt; './lib' ,
    },
    [ sub { $test_dbh }, {} ]
);</code></pre>

<p>The next step is to connect everything to <a href="http://search.cpan.org/perldoc?DBIx::Class::Migration">DBIx::Class::Migration</a>&mdash;but first things first.</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/04/27/make-a-dbic-schema-from-ddl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embrace the Little Conveniences</title>
		<link>http://www.modernperlbooks.com/mt/2012/04/embrace-the-little-conveniences.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/04/embrace-the-little-conveniences.html#comments</comments>
		<pubDate>Wed, 25 Apr 2012 18:55:09 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[codereuse]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[modernperl]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=ff38d1c7a63fad035dc6c3c1098e8a60</guid>
		<description><![CDATA[When Perl 6 introduced say (like print, but appends a newline) I had some skepticism. Yes, the Modern::Perl module was as much a polemic as it was a convenience. I know File::Slurp exists, but my fingers by now know how...]]></description>
			<content:encoded><![CDATA[
        <p>When Perl 6 introduced <code>say</code> (like <code>print</code>, but
appends a newline) I had some skepticism.</p>

<p>Yes, the <a href="http://search.cpan.org/perldoc?Modern::Perl">Modern::Perl</a> module was as much a polemic as it was a convenience.</p>

<p>I know <a href="http://search.cpan.org/perldoc?File::Slurp">File::Slurp</a>
exists, but my fingers by now <em>know</em> how to read from a file in a single
line of (impenetrable to the uninitiated) code:</p>

<pre><code>my $text = do { local (@ARGV, $/) = $file; <> };</code></pre>

<p>... and in each case, my initial feeling of "Why bother? What does that
offer? How silly!" were wrong. In every one of these cases, the ability to
write (and the requirement to <em>read</em>) less code has made my code
better.</p>

<p>With <code>say</code> I don't have to worry about single- versus
double-quotes, or even quoting at all sometimes. With <code>use
Modern::Perl;</code>, I don't have to worry about enabling various features and
pragmas. With <code>File::Slurp</code>, all I have to care about when reading
from a file is typing <code>read_file( $path )</code>.</p>

<p>None of these are big deals on their own, but they're little details I don't
have to worry about anymore. The same principle which says that <a
href="http://search.cpan.org/perldoc?Proc::Fork">Proc::Fork</a> is easier to
manage than writing your own forking code (I've written far too much of my own
forking code) applies.</p>

<p>Sometimes getting the little nuisances out of the way makes me more
productive and ready to tackle the big nuisances. Maybe saving my brainpower
for complicated problems (what's the standard deviation from a least square
fit?) is a better approach to typing my own <code>read_file()</code> function
on every project.</p>

<p>As silly as it once seemed to use a CPAN module for a one liner, I've
realized that <em>not</em> reusing good code is even sillier.</p>

        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/04/25/embrace-the-little-conveniences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perlbuzz news roundup for 2012-04-23</title>
		<link>http://feedproxy.google.com/~r/PerlBuzz/~3/eDe_PnR4_yg/perlbuzz-news-roundup-for-2012-04-23.html</link>
		<comments>http://feedproxy.google.com/~r/PerlBuzz/~3/eDe_PnR4_yg/perlbuzz-news-roundup-for-2012-04-23.html#comments</comments>
		<pubDate>Mon, 23 Apr 2012 15:14:19 +0000</pubDate>
		<dc:creator>Andy Lester</dc:creator>
				<category><![CDATA[Code craft]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=3085f52024d85d6ee4fa61829b13487c</guid>
		<description><![CDATA[These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com. User-friendly CLI apps with MooseX::App (blogs.perl.org) An age report for git repos (blog.urth.org) Sane time zone management in...]]></description>
			<content:encoded><![CDATA[
        <p>
These links are collected from the
<a href="http://twitter.com/perlbuzz">Perlbuzz Twitter feed</a>.
If you have suggestions for news bits, please mail me at
<a href="mailto:andy@perlbuzz.com">andy@perlbuzz.com</a>.
</p>

<ul>

<li>User-friendly CLI apps with MooseX::App (<a href="http://blogs.perl.org/users/maros/2012/04/user-friendly-command-line-apps-with-less-suffering.html">blogs.perl.org</a>)</li>
<li>An age report for git repos (<a href="http://blog.urth.org/2012/04/git-age-report.html">blog.urth.org</a>)</li>
<li>Sane time zone management in PostgreSQL (<a href="http://justatheory.com/computers/databases/postgresql/use-timestamptz.html">justatheory.com</a>)</li>
<li>Integrating Perl with the nginx web server (<a href="http://blogs.perl.org/users/alexandr_gomoliako/2012/04/nginx-perl-the-state-of-things.html">blogs.perl.org</a>)</li>
<li>The price of cleverness (YAML is not safe) (<a href="http://blogs.perl.org/users/ovid/2012/04/the-price-of-cleverness-yaml-is-not-safe.html">blogs.perl.org</a>)</li>
<li>By the way, all Perlbuzz tweets are from the command line via <a href="http://twitter.com/ttytter">@ttytter</a>, a Perl 5 Twitter client</li>
<li>Expanded the "More Tools" page of the ack website: (<a href="http://betterthangrep.com/more-tools/">betterthangrep.com</a>) Help your users by including alternatives for them to choose from!</li>
<li>Recapping DC-Baltimore Perl Workshop 2012 (<a href="http://domm.plix.at/perl/2012_04_19_dc_baltimore_perl_workshop.html">domm.plix.at</a>)</li>
<li>Poet, a web framework for Mason (<a href="http://www.openswartz.com/2012/04/21/poet-a-web-framework-for-mason/">openswartz.com</a>)</li>
<li>Writing init scripts w/Daemon::Control (<a href="http://hashbang.ca/2012/04/16/wherein-i-realize-the-bliss-of-writing-init-scripts-with-daemoncontrol/">hashbang.ca</a>)</li>
<li>Padre 0.96 released. (<a href="http://blogs.perl.org/users/peter_lavender/2012/04/padre-096-has-been-released.html">blogs.perl.org</a>)</li>
</ul>

        
    <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=eDe_PnR4_yg:UiDbxnPu2NI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=eDe_PnR4_yg:UiDbxnPu2NI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=eDe_PnR4_yg:UiDbxnPu2NI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=eDe_PnR4_yg:UiDbxnPu2NI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=eDe_PnR4_yg:UiDbxnPu2NI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=eDe_PnR4_yg:UiDbxnPu2NI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PerlBuzz/~4/eDe_PnR4_yg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/04/23/perlbuzz-news-roundup-for-2012-04-23/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dependencies, Minimizers, and Regressing to JavaScript</title>
		<link>http://www.modernperlbooks.com/mt/2012/04/dependencies-minimizers-and-regressing-to-javascript.html</link>
		<comments>http://www.modernperlbooks.com/mt/2012/04/dependencies-minimizers-and-regressing-to-javascript.html#comments</comments>
		<pubDate>Fri, 20 Apr 2012 18:29:54 +0000</pubDate>
		<dc:creator>chromatic</dc:creator>
				<category><![CDATA[cpan]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[modernperl]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=87d8f71e8be6ad2f75438fd9553c24bd</guid>
		<description><![CDATA[JavaScript is Perl 4 with first class functions, slightly better lexicals, better implementations, and more users. (If that hasn't offended you yet, note that that sentence doesn't include &#34;a better type system&#34;, on purpose.) While you can do some amazing...]]></description>
			<content:encoded><![CDATA[
        <p>JavaScript is Perl 4 with first class functions, slightly better lexicals,
better implementations, and more users.</p>

<p>(If that hasn't offended you yet, note that that sentence doesn't include "a
better type system", <em>on purpose</em>.)</p>

<p>While you can do some amazing things with modern JavaScript (see also <a
href="http://clubcompy.com/">ClubCompy</a>, a retro-style programming
environment designed for kids of all ages, for which we have a compiler and
interpreter written in JavaScript), its flaws of language and ecosystem are
obvious. The latter are obviously products of its environment.</p>

<p>Consider: you don't have anything like the CPAN for JavaScript in the
browser. (Yes, I'm aware of <a href="http://npmjs.org/">NPM</a>. No, it doesn't
count. The <em>point</em> of client-side JavaScript delivered from a web page
is that you don't have to have anything other than a web browser installed.)</p>

<p>Consider: this means you either make lots of requests for your dependent
libraries (jQuery, any plugins you use, the JavaScript you've written), which
is good in that if you use these libraries unmodified and load them from a
public CDN, there's a chance some cache in the middle will already have them
cached, but you still pay the network penalty for loading all of those
libraries <em>n</em> at a time or you glue them all together on the server side
somehow and send the client only one thing, except that it's only cached for
your site.</p>

<p>Also, if you find a bug in a dependency, you get to regenerate that big blob
of code. (If you <em>don't</em> find that bug, you get to live with it.)</p>

<p>I think about these things when I see <a
href="http://blogs.perl.org/users/ovid/2012/04/the-price-of-cleverness-yaml-is-not-safe.html">a
big lump of code stuffed into YAML.pm</a>. Because we've left 1994 behind in
the Perl world, we're able to take advantage of an amazing library distribution
and dependency management system in the CPAN, where installing dependencies
(and knowing they pass their tests) is so well understood that it's an
exceptional condition when it <em>doesn't</em> work. In the past couple of
years, installations have become so easy thanks to newer tools like perlbrew
and cpanm that (if you're in the know) it's easier to manage code this way than
to consider not.</p>

<p>... except for when you <a
href="https://github.com/schwern/test-more/blob/Test-Builder1.5/lib/TB2/Mouse.pm">stuff
generated code in your repository instead of as a dependency</a>.
(Test::Builder is a strange case. You want your underlying test library to be
as stupidly simple as possible and not to rely on anything else so it's as
unlikely to fail as possible and as impossible to interfere with what you're
testing as ever.)</p>

<p>Now when there's a bug in the dependency in the generated code, everything
which uses the dependency has to be updated too. Read carefully. You can't
merely update the dependency. You have to know everything on which it depends
and wait for the authors to get around to updating their generated code.)</p>

<p>I admit, I'll probably never understand the mindset which says "I'm
distributing software for end-users to install in the worst possible way so
that they won't have to install software." I understand the use of things like
<a href="http://search.cpan.org/perldoc?App::FatPacker">App::FatPacker</a> to
make one-file installations possible, but actively distributing generated code
in CPAN distributions? Where CPAN has a working dependency resolution model
already in place? Where your distribution is already an upstream dependency of
thousands of other distributions?</p>

<p>I just don't understand it. I understand that the business of shipping
software is the art of managing competing needs, but I can't see how optimizing
for fragility helps anyone.</p>
        
    ]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/04/20/dependencies-minimizers-and-regressing-to-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perlbuzz news roundup for 2012-04-16</title>
		<link>http://feedproxy.google.com/~r/PerlBuzz/~3/4KNYAYOdjgA/perlbuzz-news-roundup-for-2012-04-16.html</link>
		<comments>http://feedproxy.google.com/~r/PerlBuzz/~3/4KNYAYOdjgA/perlbuzz-news-roundup-for-2012-04-16.html#comments</comments>
		<pubDate>Mon, 16 Apr 2012 14:37:42 +0000</pubDate>
		<dc:creator>Andy Lester</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://perlblogs.com/?guid=7b64e1d8374d386abdbc946d5a9cb64c</guid>
		<description><![CDATA[These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com. K=R=P (Kindness = Repeat business = Profit) says @tom_peters. I say that for open source, K=U=G+S, Kindness =...]]></description>
			<content:encoded><![CDATA[
        <p>
These links are collected from the
<a href="http://twitter.com/perlbuzz">Perlbuzz Twitter feed</a>.
If you have suggestions for news bits, please mail me at
<a href="mailto:andy@perlbuzz.com">andy@perlbuzz.com</a>.
</p>

<ul>

<li>K=R=P (Kindness = Repeat business = Profit) says <a href="http://twitter.com/tom_peters">@tom_peters</a>. I say that for open source, K=U=G+S, Kindness = Users = Growth+Success.</li>
<li>You probably don't want to be using use_ok() (<a href="http://www.modernperlbooks.com/mt/2012/04/use-ok-is-broken-because-require-is-broken.html">modernperlbooks.com</a>)</li>
<li>Interpolate, concatenate or join? (<a href="http://perlmonks.org/?node_id=964608">perlmonks.org</a>)</li>
<li>Quick-n-dirty tool to send messages to HipChat (<a href="http://blogs.perl.org/users/jason_a_crome/2012/04/simple-hipchat-notifier.html">blogs.perl.org</a>)</li>
<li>Painless RSS processing with Mojo (<a href="http://blogs.perl.org/users/brian_d_foy/2012/04/painless-rss-processing-with-mojo.html">blogs.perl.org</a>)</li>
<li>RT <a href="http://twitter.com/chromatic_x">@chromatic_x</a> If you use SQLite for your CPAN distribution's tests, consider an in-memory database. Helps parallelism/Reduces disk IO.</li>
<li>Explaining web programming via Plack (<a href="http://blogs.perl.org/users/ovid/2012/04/explaining-web-programming-via-plack.html">blogs.perl.org</a>)</li>
<li>Common Perl pitfalls (<a href="http://perlmonks.org/?node_id=964216">perlmonks.org</a>)</li>
<li>Test::WWW::Mechanize adds scraping functions (<a href="http://perlbuzz.com/2012/04/testwwwmechanize-adds-scraping-functions.html">perlbuzz.com</a>)</li>
</ul>

        
    <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=4KNYAYOdjgA:oKcSIaCh1Ao:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=4KNYAYOdjgA:oKcSIaCh1Ao:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=4KNYAYOdjgA:oKcSIaCh1Ao:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=4KNYAYOdjgA:oKcSIaCh1Ao:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?i=4KNYAYOdjgA:oKcSIaCh1Ao:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PerlBuzz?a=4KNYAYOdjgA:oKcSIaCh1Ao:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PerlBuzz?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PerlBuzz/~4/4KNYAYOdjgA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://perlblogs.com/2012/04/16/perlbuzz-news-roundup-for-2012-04-16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

