<?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>bluefeet</title>
	<atom:link href="http://blog.bluefeet.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bluefeet.net</link>
	<description>Yet another Perl Hacker weblog</description>
	<lastBuildDate>Sun, 24 Jan 2010 19:16:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Robust DBI Transaction and Connection Handling</title>
		<link>http://blog.bluefeet.net/2010/01/robust-dbi-transaction-and-connection-handling/</link>
		<comments>http://blog.bluefeet.net/2010/01/robust-dbi-transaction-and-connection-handling/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 05:27:25 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[DBIC]]></category>
		<category><![CDATA[dbix-class]]></category>
		<category><![CDATA[DBIx::Class]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=210</guid>
		<description><![CDATA[Edit: It turns out there is already a module on CPAN that does exactly what I talked about here.  Its called DBIx::Connector.  I haven&#8217;t tried it yet, but it looks like the guy that wrote it designed it with input from the DBIC guys.
I&#8217;m a big fan of DBIx::Class.  Among DBIC&#8217;s many [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><b>Edit:</b> It turns out there is already a module on CPAN that does exactly what I talked about here.  Its called <a href="http://search.cpan.org/perldoc?DBIx::Connector">DBIx::Connector</a>.  I haven&#8217;t tried it yet, but it looks like the guy that wrote it designed it with input from the DBIC guys.</p></blockquote>
<p>I&#8217;m a big fan of <a href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a>.  Among DBIC&#8217;s many great features is its superb transaction and connection handling via <a href="http://search.cpan.org/perldoc?DBIx::Class::Storage::DBI">DBIx::Class::Storage::DBI</a>.  When I&#8217;m using raw DBI I feel like I&#8217;m missing these core components.  I should always be able to expect robust transaction and connection handling.</p>
<p>I started playing around with creating a new CPAN module (something like DBIx::Robust, DBIx::Transaction, etc&#8230;) but each time I dove in to it I kept coming to the conclusion that DBIC&#8217;s DBI storage drivers provide everything I need and I would just be shooting myself in the foot by either porting DBIx::Class::Storage::DBI to a DBIC independent API or by writing it from scratch.</p>
<p>Before I go any further, let me show you how attractive and awesome DBIC&#8217;s storage layer is:</p>
<ul>
<li>Transactions may be nested, even without savepoints.</li>
<li>Transaction savepoints can automatically be tracked allowing for reliable and incremental rollbacks.</li>
<li>The appropriate DateTime::Format class is automatically determined based on the type of database.</li>
<li>All database calls efficiently pass through a layer that detects stale connections that will attempt to re-connect to a database.</li>
</ul>
<p><a href="http://images.google.com/images?gbv=2&#038;q=kung+fu+panda+opening&#038;btnG=Search&#038;start=0"><i>&#8220;There is no charge for awesomeness, or attractiveness.&#8221;</i></a></p>
<p>The DBIx::Class::Storage::DBI pod illustrates all this in a round-about way: <i>&#8220;If you set AutoCommit => 0 in your connect info, then you are always in an assumed transaction between commits, and you&#8217;re telling us you&#8217;d like to manage that manually. A lot of the magic protections offered by this module will go away. We can&#8217;t protect you from exceptions due to database disconnects because we don&#8217;t know anything about how to restart your transactions. You&#8217;re on your own for handling all sorts of exceptional cases if you choose the AutoCommit => 0 path, just as you would be with raw DBI.&#8221;</i></p>
<p>This stuff is really powerful, and we should never have to work with databases in Perl without it.  But, currently, it is only meant to work under DBIC, which is a shame.  I&#8217;m betting that DBIx::Class::Storage::DBI could be used directly, bypassing DBIC completely.  There is some DBIC stuff layered in there, but that should be ignorable.</p>
<p>What do the rest of you think?  Has anyone considered moving this logic out in to a generic distribution that isn&#8217;t DBIC specific?  Is there merit in what I&#8217;m talking about?  Does anyone use DBIx::Class::Storage::DBI directly, bypassing DBIC?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2010/01/robust-dbi-transaction-and-connection-handling/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>use HTML::FormHandler;</title>
		<link>http://blog.bluefeet.net/2009/10/use-htmlformhandler/</link>
		<comments>http://blog.bluefeet.net/2009/10/use-htmlformhandler/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 16:00:45 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[CPAN]]></category>
		<category><![CDATA[Moose]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=206</guid>
		<description><![CDATA[I&#8217;ve been meaning to give HTML::FormHandler a try for quite some time now.  Over the weekend I converted a form from some home-grown form validation and html generation to use HTML::FormHandler instead.  HTML::FormHandler was inspired by, and quasi-forked from, Form::Processor.  There are many options for processing forms, such as FormValidator::Simple (Catalyst&#8217;s default) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to give <a href="http://search.cpan.org/perldoc?HTML::FormHandler">HTML::FormHandler</a> a try for quite some time now.  Over the weekend I converted a form from some home-grown form validation and html generation to use HTML::FormHandler instead.  HTML::FormHandler was inspired by, and quasi-forked from, <a href="http://search.cpan.org/perldoc?Form::Processor">Form::Processor</a>.  There are many options for processing forms, such as <a href="http://search.cpan.org/perldoc?FormValidator::Simple">FormValidator::Simple</a> (Catalyst&#8217;s default) and <a href="http://search.cpan.org/perldoc?Data::FormValidator">Data::FormValidator</a>, to name a few.</p>
<p>Up until now I&#8217;ve always thought that the existing form handling/validating modules on CPAN were incredibly lacking.  They all have these crazy and inconsistent APIs that in the end limit what you are able to do.  I don&#8217;t expect a form validation API to handle every possible situation, but I do expect it to provide a consistent API that is well documented and allows me to easily extend if I need additional functionality.  Plus none of them use Moose (AFAIK), which isn&#8217;t just me being a Moose evangelist, its also practical because Moose provides mechanisms to extend functionality via roles and to provide reusable validation with <a href="http://search.cpan.org/perldoc?MooseX::Types">MooseX::Types</a>.</p>
<p>HTML::FormHandler solves these issues.  HTML::FormHandler can be a complete end-to-end solution for declaring form fields and types, applying server-side validation, generating the HTML for a form, and applying form submits to the database.  Almost everything and the kitchen sink is there, except client-side form validation, which can be added separately of course.  Normally a &#8220;do everything&#8221; package scares me, especially for something like form validation.  But, Gerda Shank (the author of HTML::FormHandler) did a great job splitting out the various pieces of HTML::FormHandler so that any piece of the form handling process can be subverted to your own needs, and there is <a href="http://search.cpan.org/perldoc?HTML::FormHandler::Manual">copious amounts of documentation</a> explaining how to do so.</p>
<p>The <a href="http://search.cpan.org/perldoc?HTML::FormHandler::Manual::Intro">HTML::FormHandler::Manual::Intro</a> does a great job introducing HTML::FormHandler.</p>
<p>There are a few downsides to this module&#8217;s current state.  It is relatively new and is still stabilizing.  For example, just recently the results of form validation were separated from the form object itself.  This is a huge fundamental change, but a necessary one.  Also, the concept of widgets was recently introduced.  Widgets are a great way to extend and customize the display of form fields, and the form as a whole.  But, this was just introduced and is still experimental, and has some rough edges.  Despite this, the widget design is very promising and I ended up using it myself (thanks to <a href="http://search.cpan.org/perldoc?HTML::FormHandler::Manual::Rendering">HTML::FormHandler::Manual::Rendering</a>) as my preferred rendering method.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/10/use-htmlformhandler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 10 Reasons to use Perl</title>
		<link>http://blog.bluefeet.net/2009/09/top-10-reasons-to-use-perl/</link>
		<comments>http://blog.bluefeet.net/2009/09/top-10-reasons-to-use-perl/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 05:34:28 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Beer]]></category>
		<category><![CDATA[Fohawks]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Moose]]></category>
		<category><![CDATA[Perl 5]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ryan Seacrest]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=200</guid>
		<description><![CDATA[You should use Perl because&#8230;
10. Real Perl coders don&#8217;t have fohawks.
9. Perl has nothing to do with Ryan Seacrest.
8. Beer improves Perl.
7. It comes with a 20-sided die for all that TIMTOWTDI.
6. It has nothing to do with PHP.
5. Captain Picard writes perl.
4. There is no better place to get Moo seX.
3. It grows on [...]]]></description>
			<content:encoded><![CDATA[<p>You should use Perl because&#8230;</p>
<p>10. Real Perl coders don&#8217;t have <a href="http://images.google.com/images?q=ruby+rhod">fohawks</a>.<br />
9. Perl has nothing to do with <a href="http://www.ryanseacrest.com/">Ryan Seacrest</a>.<br />
8. Beer <a href="http://xkcd.com/323/">improves</a> Perl.<br />
7. It comes with a 20-sided die for all <a href="http://dictionary.reference.com/browse/that">that</a> TIMTOWTDI.<br />
6. It has nothing to do with <a href="http://www.php.com/">PHP</a>.<br />
5. <a href="http://blob.perl.org/books/impatient-perl/iperl.html#12_Procedural_Perl">Captain Picard</a> writes perl.<br />
4. There is no better place to get <a href="http://www.thefrisky.com/post/246-man-arrested-twice-for-having-sex-with-his-cow-and-other-bizarre-crimes/">Moo seX</a>.<br />
3. It <a href="http://www.scmrrs.org/">grows</a> on you.<br />
2. <a href="http://users.wfu.edu/ellwjd5/images/Atomic%20Bomb.gif">IE8</a> was not written in Perl.</p>
<p>&#8230; drum roll &#8230;</p>
<p>1. You can <a href="http://www.yapceurope.org/2001/proceedings/26/fractalcamel/camel_00.html">write this</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/09/top-10-reasons-to-use-perl/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>IE8, another screwed up version.</title>
		<link>http://blog.bluefeet.net/2009/09/ie8-another-screwed-up-version/</link>
		<comments>http://blog.bluefeet.net/2009/09/ie8-another-screwed-up-version/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 18:32:03 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=187</guid>
		<description><![CDATA[I was really hoping that Internet Explorer version 8 (IE8) would finally be the version of IE where Microsoft stepped up to the plate and produced a fast browser, with few bugs, less Microsoft-only features, and a good and modern UI.
I&#8217;m the kind of guy that holds judgment for a very long time, sometimes too [...]]]></description>
			<content:encoded><![CDATA[<p>I was really hoping that Internet Explorer version 8 (IE8) would finally be the version of IE where Microsoft stepped up to the plate and produced a fast browser, with few bugs, less Microsoft-only features, and a good and modern UI.</p>
<p>I&#8217;m the kind of guy that holds judgment for a very long time, sometimes too long.  So it comes with great sadness that I announce that IE8 is not the browser I was hoping for.  It is riddled with bugs, the rendering engine crashes on many web sites, and it is SLOW.  Its the slowest browser of them all as far as I can tell.  It renders many web-2.0&#8242;ish sites with teeth-gritting sluggishness.  Once rendered, javascript animations tend to be jumpy as well.  I&#8217;ve found several cases where the event engine is even more screwed up than it was in IE7.</p>
<p>If you&#8217;re a web developer and IE8 is causing the same pain for you as it has for me, consider adding this to your HTML*:</p>
<div class="codecolorer-container html4strict vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;X-UA-Compatible&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;IE=EmulateIE7&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></div></div>
<p><small>* This should be the very first tag after the opening &lt;head&gt; tag.</small></p>
<p>This will force IE8 to run in IE7 compatibility mode.  When in IE7 compatibility mode IE8 will not crash nearly as often and will render your HTML/CSS/JS much more predictably and act more similar to how Chrome and FireFox behave.</p>
<p>I don&#8217;t understand why Microsoft keeps doing this.  They have all the power in the world to <b>WIN</b> the browser war, but they are just going to keep failing with crap software like this and loose one more market to Google.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/09/ie8-another-screwed-up-version/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up mod_perl6: Part 1</title>
		<link>http://blog.bluefeet.net/2009/08/setting-up-mod_perl6-part-1/</link>
		<comments>http://blog.bluefeet.net/2009/08/setting-up-mod_perl6-part-1/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 17:36:23 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mod_parrot]]></category>
		<category><![CDATA[mod_perl6]]></category>
		<category><![CDATA[parrot]]></category>
		<category><![CDATA[perl6]]></category>
		<category><![CDATA[rakudo]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=182</guid>
		<description><![CDATA[The Thousand Oaks Mongers are going to host a half-day Perl 6 hackathon next Saturday (the 22nd) as already talked about here.  So far we have three people involved, including myself.  We&#8217;d like to create a web site that displays aggregated data from other web sites, such as twitter. We&#8217;ve divided our tasks [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://thousand-oaks-perl.org/">Thousand Oaks Mongers</a> are going to host a half-day Perl 6 hackathon next Saturday (the 22nd) as already talked about <a href="http://web-hero.net/adamantium/?p=27">here</a>.  So far we have three people involved, including myself.  We&#8217;d like to create a web site that displays aggregated data from other web sites, such as twitter. We&#8217;ve divided our tasks up between the three of us:</p>
<ul>
<li><a href="http://www.asciiville.com/">Todd Prest</a>: Database access of some sort.  So far Todd has gotten sqlite 3 mostly working and has learned a lot about DBDI (the DBI for perl6) and other bits.</li>
<li><a href="http://web-hero.net/adamantium/">Shawn Faison</a>: Write some libraries to pull data from various web sites.</li>
<li>Aran Deltac (me): Get mod_perl6 up and running.</li>
</ul>
<p>So far my adventures in getting mod_perl6 working have been stalled.  Getting rakudo and parrot setup is EASY, just follow <a href="http://rakudo.org/how-to-get-rakudo">these instructions</a>.  Once that was setup I went and grabbed <a href="http://www.parrot.org/mod_parrot">mod_parrot</a>.  I first grabbed the version 0.05 tarball which failed on make.  So, I figured that since 0.05 was released in January its probably way behind the currnet parrot/rakuda development and that I should try out the latest bleeding-edge version of mod_parrot.  This time mod_parrot built fine (with lots of warnings) and then failed on make test.</p>
<p>dukeleta over at <a href="irc://irc.perl.org/parrot">#parrot</a> valiantly tried to help me resolve the issue, but in the end he figured that the lead developer of mod_parrot, Jeff Horwitz (jhorwitz), would be able to help me out.</p>
<p>The details of my issues are illustrated in this <a href="http://scsys.co.uk:8001/32554">no paste</a>.</p>
<p>I&#8217;m not sure how to get ahold of Jeff (he hasn&#8217;t been on #parrot for almost a month) and I need to go with the family to the <a href="http://venturacountyfair.org/">fair</a>.</p>
<p>One way or another, before the hackathon, I&#8217;ll either have to find Jeff, figure out how to fix mod_parrot to work, or run an older version of parrot/rakudo that does work with mod_parrot.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/08/setting-up-mod_perl6-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>use Path::Class;</title>
		<link>http://blog.bluefeet.net/2009/08/use-pathclass/</link>
		<comments>http://blog.bluefeet.net/2009/08/use-pathclass/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 05:26:10 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=169</guid>
		<description><![CDATA[The CPAN (Comprehensive Perl Archive Network) distribution, Path::Class, provides a simple OO API alternative to the built-in perl file IO functions such as open, opendir, stat, etc.  Code written to use Path::Class tends to be smaller (concise, easier to maintain, etc) than similar code that uses the standard built-in functions.
Here is an example of [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://search.cpan.org/">CPAN</a> (Comprehensive Perl Archive Network) distribution, <a href="http://search.cpan.org/perldoc?Path::Class">Path::Class</a>, provides a simple OO API alternative to the built-in perl file IO functions such as <a href="http://perldoc.perl.org/functions/open.html">open</a>, <a href="http://perldoc.perl.org/functions/opendir.html">opendir</a>, <a href="http://perldoc.perl.org/functions/stat.html">stat</a>, etc.  Code written to use Path::Class tends to be smaller (concise, easier to maintain, etc) than similar code that uses the standard built-in functions.</p>
<p>Here is an example of how a small utility might be written <strong>without</strong> Path::Class:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Find all files that are less than 10k in size...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'/some/dir'</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/opendir.html"><span style="color: #000066;">opendir</span></a><span style="color: #009900;">&#40;</span> DIR<span style="color: #339933;">,</span> <span style="color: #0000ff;">$dir</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@files</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/readdir.html"><span style="color: #000066;">readdir</span></a><span style="color: #009900;">&#40;</span> DIR <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/closedir.html"><span style="color: #000066;">closedir</span></a><span style="color: #009900;">&#40;</span> DIR <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@files</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">next</span> <span style="color: #b1b100;">if</span> <span style="color: #339933;">!-</span>f <span style="color: #ff0000;">&quot;$dir/$file&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/stat.html"><span style="color: #000066;">stat</span></a> <span style="color: #ff0000;">&quot;$dir/$file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>7<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> 1024 <span style="color: #339933;">*</span> 10<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;$dir/$file<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>And here it is re-written to use Path::Class:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">use</span> Path<span style="color: #339933;">::</span><span style="color: #006600;">Class</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Find all files that are less than 10k in size...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dir</span> <span style="color: #339933;">=</span> dir<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'/some/dir'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$dir</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">next</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">stat</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> 1024 <span style="color: #339933;">*</span> 10<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;$file<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Using Path::Class is a no-brainer when you compare `<code class="codecolorer perl vibrant"><span class="perl"><span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/stat.html"><span style="color: #000066;">stat</span></a> <span style="color: #ff0000;">&quot;$dir/$file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#93;</span></span></code>` with `<code class="codecolorer perl vibrant"><span class="perl"><span style="color: #0000ff;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">stat</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code>`.</p>
<p>One of Path::Class&#8217;s greatest stengths is that it is very simple and many of the features it provides are done so by glueing with other well-tested modules that have been on CPAN for a long time.  These modules include <a href="http://search.cpan.org/perldoc?IO::Dir">IO::Dir</a>, <a href="http://search.cpan.org/perldoc?IO::File">IO::File</a>, <a href="http://search.cpan.org/perldoc?File::Path">File::Path</a>, and <a href="http://search.cpan.org/perldoc?File::stat">File::stat</a>.</p>
<p>Some other highlights include:</p>
<ul>
<li>Has a recurse() method that provides an enhanced File::Find-like interface.</li>
<li>Works equally well with absolute and relative paths, and can correctly convert between the two.</li>
<li>Symlinks are handled correctly and there are methods to interact with them.</li>
<li>Works equally well under different operating systems, such as Linux and Windows.</li>
<li>The interface, for me anyway, is about as intuitive as it gets.  Very well designed to DWIM.</li>
</ul>
<p>I&#8217;ve been using this module at $work for a while now and am very happy with it and have had coworkers tell me, after they gave it a try, how much cleaner their code ended up being because they used this module.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/08/use-pathclass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to Catalyst 5.8</title>
		<link>http://blog.bluefeet.net/2009/07/upgrading-to-catalyst-5-8/</link>
		<comments>http://blog.bluefeet.net/2009/07/upgrading-to-catalyst-5-8/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 00:15:44 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[Moose]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=157</guid>
		<description><![CDATA[Over the last few days at $work I&#8217;ve been upgrading Catalyst from 5.7 to 5.8.  This new version of catalyst, released in April, has been completely overhauled to use Moose for it&#8217;s OO system, among other enhancements and bug fixes.
I found that the Catalyst::Manual::CatalystAndMoose manual was a great starting point to using Moose with [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last few days at $work I&#8217;ve been upgrading Catalyst from 5.7 to 5.8.  This new version of catalyst, released in April, has been completely overhauled to use <a href="http://search.cpan.org/perldoc?Moose">Moose</a> for it&#8217;s OO system, among other enhancements and bug fixes.</p>
<p>I found that the <a href="http://search.cpan.org/perldoc?Catalyst::Manual::CatalystAndMoose">Catalyst::Manual::CatalystAndMoose</a> manual was a great starting point to using Moose with Catalyst.  Also, <a href="http://search.cpan.org/perldoc?Catalyst::Upgrading">Catalyst::Upgrading</a> has specific points to consider when upgrading to 5.8.  During the initial install of Catalyst 5.8 I was told that I had a few related modules installed, that while not Catalyst prerequisites, I should upgrade them as they were known to fail on the new Catalyst.  I was lucky that I caught this message, as cpan did not pause to wait for me to read it and went on its marry way building, testing, and installing Catalyst.</p>
<p>Once installed I went ahead and also upgraded some related modules we use such as <a href="http://search.cpan.org/perldoc?Catalyst::Plugin::Authentication">Catalyst::Plugin::Authentication</a>, <a href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a>, <a href="http://search.cpan.org/perldoc?Catalyst::Plugin::Session">Catalyst::Plugin::Session</a>, <a href="http://search.cpan.org/perldoc?Catalyst::Authentication::Store::DBIx::Class">Catalyst::Authentication::Store::DBIx::Class</a>, etc.  This way I could test all these upgrades all at once instead of one at a time.</p>
<p>Next I modified all my custom plugins to use <a href="http://search.cpan.org/perldoc?MRO::Compat">MRO::Compat</a> instead of <a href="http://search.cpan.org/perldoc?Class::C3">Class::C3</a> per the documentation in <a href="http://search.cpan.org/perldoc?Class::C3::Adopt::NEXT">Class::C3::Adopt::NEXT</a>.  But, then I realized I might as well just rewrite all my plugins as <a href="http://search.cpan.org/perldoc?Moose::Role">Moose::Role</a>s as its pretty easy to convert a plugin to a role and you end up with much cleaner code.</p>
<p>I started Apache up and things mostly worked.  There were a few backwards incompatibilities that I wasn&#8217;t aware of, such as there were a few cases where developers had done this:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">sub</span> <a href="http://perldoc.perl.org/functions/index.html"><span style="color: #000066;">index</span></a> <span style="color: #339933;">:</span> Local <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span></div></div>
<p>Instead of:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">sub</span> <a href="http://perldoc.perl.org/functions/index.html"><span style="color: #000066;">index</span></a> <span style="color: #339933;">:</span> Private <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span></div></div>
<p>In our previous version of catalyst (5.7) using :Local, while not documented, worked just like :Private if the subroutine was named index.  In 5.8 only :Private will cause a handler named index to be the default handler if the URL resolves to the controller only.  This was an easy fix.  There were a couple other small issues, but nothing major.  I found and fixed <a href="https://rt.cpan.org//Ticket/Display.html?id=48084">a bug</a> in <a href="http://search.cpan.org/perldoc?Catalyst::Model::DBIC::Schema">Catalyst::Model::DBIC::Schema</a> and added the support for the compute() method to <a href="Catalyst::Plugin::Cache">Catalyst::Plugin::Cache</a>.  Both of these changes reduced the amount of changes I needed to make to my own code.</p>
<p>A couple hours in to it I was upgraded and everything was working.  Of course I spent the next few days upgrading/enhancing/rewriting Catalyst bits that could be done much more elegantly, and with less code, using Moose.</p>
<p>On a side note, during the upgrade I found this great quote in <a href="http://search.cpan.org/perldoc?Catalyst::Model::Adaptor">Catalyst::Model::Adaptor</a>:</p>
<blockquote><p>Catalyst is glue, not a way of life!</p></blockquote>
<p>Amen!  Most people, myself included, start out by writing all their business logic in their Controllers because that is what <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">MVC</a> told them to do.  Don&#8217;t do it!  Catalyst is meant to be a GLUE &#8211; most of your application should be written in a way that it doesn&#8217;t give a flying crap how, or by whom, it is used.  Put your business logic in modules that optionally expose themselves as Models (perhaps via <a href="http://search.cpan.org/perldoc?Catalyst::Model::Adaptor">Catalyst::Model::Adaptor</a>) or just by adding a use statement in your controller that then uses that module.  Your controllers should be little more than code to glue a data source with the view and provide some input validation.</p>
<p>I&#8217;ve been waiting a long time for this Moosification and its been a joy working with this new Catalyst.  Next up to bat will be the Moosification of <a href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a>!  Think we&#8217;ll get it by Christmas?  :)</p>
<p>Don&#8217;t forget to buy the new <a href="http://www.shadowcat.co.uk/blog/matt-s-trout/the-definitive-guide-to-catalyst/">Catalyst Book</a>!  If purchasing from Amazon make sure you follow <a href="http://www.amazon.com/Definitive-Guide-Catalyst-Maintainable-Applications/dp/1430223650?&#038;camp=2486&#038;linkCode=wey&#038;tag=enligperlorga-21&#038;creative=8882">this link</a> to ensure that the <a href="http://www.enlightenedperl.org/">Enlightened Perl Organisation</a> gets a cut of the sale.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/07/upgrading-to-catalyst-5-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>XS Hits Newb; Bystanders Watch in Dismay</title>
		<link>http://blog.bluefeet.net/2009/07/xs-hits-newb-bystanders-watch-in-dismay/</link>
		<comments>http://blog.bluefeet.net/2009/07/xs-hits-newb-bystanders-watch-in-dismay/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 03:53:30 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=146</guid>
		<description><![CDATA[Last year I wrote GIS::Distance::Fast to provide some much needed speedups to the pure-perl GIS::Distance.  This ::Fast version used Inline::C which isn&#8217;t all that optimal and was just a scapegoat for doing the right thing.
So, this evening I rolled up my sleeves and went to work.  I first looked at a module I [...]]]></description>
			<content:encoded><![CDATA[<p>Last year I wrote <a href="http://search.cpan.org/perldoc?GIS::Distance::Fast">GIS::Distance::Fast</a> to provide some much needed speedups to the pure-perl <a href="http://search.cpan.org/perldoc?GIS::Distance">GIS::Distance</a>.  This ::Fast version used Inline::C which isn&#8217;t all that optimal and was just a scapegoat for doing the right thing.</p>
<p>So, this evening I rolled up my sleeves and went to work.  I first looked at a module I already knew to use XS, <a href="http://search.cpan.org/perldoc?Cache::Memcached::Fast">Cache::Memcached::Fast</a>.  That was overwelming.</p>
<p>Then I went on over and read through the <a href="http://perldoc.perl.org/perlxs.html">perlxs</a> and <a href="http://perldoc.perl.org/perlxstut.html">perlxstut</a> docs.  I was STILL floundering about not sure what to do.  I then took a whack at using <a href="http://www.swig.org/">SWIG</a> (Simplified Wrapper and Interface Generator).  OhMyGodz I&#8217;m feeling overwhelmed now and still nothing works.  I&#8217;m not going to even document my attempts up until this point.</p>
<p>I then found <a href="http://www.swig.org/papers/Perl98/swigperl.htm">this document</a> that goes in to more detail about using SWIG with Perl.  The thing about this document that helped me so much is that in section 2, Perl Extension Building, it had the simplest example I had yet run in to, and it made sense!  Its kinda funny that a SWIG document was what taught me how to write my own XS without using SWIG.  :)</p>
<p>An XS distribution can contain as little as two files (well, beyond the usual Makefile.PL, etc).  A single .pm file and a .xs file is enough.  You can get more complex, if you want, of course.  Once you&#8217;ve written your Module.xs file you can run it through <code class="codecolorer bash vibrant"><span class="bash">xssubpp Module.xs <span style="color: #000000; font-weight: bold;">&gt;</span> Module.c</span></code> to see what the .c file looks like and to verify that your .xs file is correct.</p>
<p>Note that xssubpp may complain about you using types that aren&#8217;t in your typemap.  This is because xssubpp doesn&#8217;t know how to find your system&#8217;s typemap file.  You can specify a typemap file using the -typemap switch.  The file is located somewhere in your perl lib path as ExtUtils/typemap.</p>
<p>So, let&#8217;s go for an example.  Let&#8217;s make an XS module that convert hours to minutes.  I structure all my code and files as if they would be distributed as a CPAN module.  This has added benefits as you&#8217;ll see in a moment.</p>
<p>convert-hoursminutes/lib/Convert/HoursMins.pm:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://perldoc.perl.org/functions/package.html"><span style="color: #000066;">package</span></a> Convert<span style="color: #339933;">::</span><span style="color: #006600;">HoursMins</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">$VERSION</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.01</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">use</span> XSLoader<span style="color: #339933;">;</span><br />
<br />
XSLoader<span style="color: #339933;">::</span><span style="color: #006600;">load</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'Convert::HoursMins'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$VERSION</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span></div></div>
<p>convert-hoursminutes/HoursMins.xs:</p>
<div class="codecolorer-container c vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">#include &quot;EXTERN.h&quot;</span><br />
<span style="color: #339933;">#include &quot;perl.h&quot;</span><br />
<span style="color: #339933;">#include &quot;XSUB.h&quot;</span><br />
<br />
<span style="color: #993333;">double</span> convert_hours_mins<span style="color: #009900;">&#40;</span> <span style="color: #993333;">double</span> hours <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> hours <span style="color: #339933;">*</span> <span style="color: #0000dd;">60</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
MODULE <span style="color: #339933;">=</span> Convert<span style="color: #339933;">::</span><span style="color: #202020;">HoursMins</span> &nbsp;PACKAGE <span style="color: #339933;">=</span> Convert<span style="color: #339933;">::</span><span style="color: #202020;">HoursMins</span><br />
<br />
PROTOTYPES<span style="color: #339933;">:</span> DISABLE<br />
<br />
<span style="color: #993333;">double</span><br />
convert_hours_mins <span style="color: #009900;">&#40;</span>hours<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span> hours</div></div>
<p>convert-hoursmins/Makefile.PL</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">use</span> inc<span style="color: #339933;">::</span><span style="color: #006600;">Module</span><span style="color: #339933;">::</span><span style="color: #006600;">Install</span><span style="color: #339933;">;</span><br />
<br />
name &nbsp; &nbsp; <span style="color: #ff0000;">'Convert-HoursMins'</span><span style="color: #339933;">;</span><br />
all_from <span style="color: #ff0000;">'lib/Convert/HoursMins.pm'</span><span style="color: #339933;">;</span><br />
requires <span style="color: #ff0000;">'XSLoader'</span><span style="color: #339933;">;</span><br />
<br />
WriteAll<span style="color: #339933;">;</span></div></div>
<p>convert-hoursmins/t/00_basic.t</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> Test<span style="color: #339933;">::</span><span style="color: #006600;">More</span> tests <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">BEGIN</span><span style="color: #009900;">&#123;</span> use_ok<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'Convert::HoursMins'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
<br />
is<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; Convert<span style="color: #339933;">::</span><span style="color: #006600;">HoursMins</span><span style="color: #339933;">::</span><span style="color: #006600;">convert_hours_minutes</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1.5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #cc66cc;">90</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #ff0000;">'1.5 hours is 90 minutes'</span><span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Now lets see if it worked:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">perl</span> Makefile.PL<br />
<span style="color: #c20cb9; font-weight: bold;">make</span><br />
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #7a0874; font-weight: bold;">test</span></div></div>
<p>Bottom line for me is XS isn&#8217;t all that hard when your C code isn&#8217;t all that complex.  SWIG is overkill for small stuff.  But for large swaths of C code I bet SWIG saves lives.  Also, XS is a little arcane, but its not too bad.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/07/xs-hits-newb-bystanders-watch-in-dismay/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>$(document).ready() Shortcut</title>
		<link>http://blog.bluefeet.net/2009/07/document-ready-shortcut/</link>
		<comments>http://blog.bluefeet.net/2009/07/document-ready-shortcut/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 21:54:32 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=144</guid>
		<description><![CDATA[When writing jquery you almost always put your code within a ready block:
$&#40;document&#41;.ready&#40;function&#40;&#41;&#123;
&#160; &#160; // Code...
&#125;&#41;;
And I always forget the exact syntax.  I just found that jQuery has a shortcut:
$&#40;function&#40;&#41;&#123;
&#160; &#160; // Code...
&#125;&#41;;
Much better!
]]></description>
			<content:encoded><![CDATA[<p>When writing jquery you almost always put your code within a ready block:</p>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Code...</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>And I always forget the exact syntax.  I just found that jQuery has a shortcut:</p>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Code...</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Much better!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/07/document-ready-shortcut/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Authoring a CPAN Module</title>
		<link>http://blog.bluefeet.net/2009/07/authoring-a-cpan-module/</link>
		<comments>http://blog.bluefeet.net/2009/07/authoring-a-cpan-module/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 05:55:24 +0000</pubDate>
		<dc:creator>bluefeet</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Perl 5]]></category>

		<guid isPermaLink="false">http://blog.bluefeet.net/?p=129</guid>
		<description><![CDATA[I&#8217;ve been authoring CPAN distribution since early 2003 with my first module being Geo::Distance.  Since then I&#8217;ve authored several other distributions and do my best to keep my RT bug list small and fix FAILs.  This process of authoring and maintaining modules on CPAN is in my top-10 list of all-time most educational [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been authoring CPAN distribution since early 2003 with my first module being <a href="http://search.cpan.org/dist/Geo-Distance/">Geo::Distance</a>.  Since then I&#8217;ve authored several <a href="http://search.cpan.org/~bluefeet/">other</a> distributions and do my best to keep my <a href="http://rt.cpan.org/Public/">RT bug list</a> small and fix <a href="http://static.cpantesters.org/">FAIL</a>s.  This process of authoring and maintaining modules on CPAN is in my top-10 list of all-time most educational experiences of my career.</p>
<p>I strongly encourage anyone that wants to become a better developer to take on the task and create a useful distribution for CPAN and/or work on an existing distro.  There are plenty of projects out there (such as <a href="http://search.cpan.org/dist/Moose/">Moose</a>, <a href="http://search.cpan.org/dist/DBIx-Class/">DBIx::Class</a>, and <a href="http://search.cpan.org/dist/Catalyst/">Catalyst</a>, to name a few) that need help and can use all the hands that they can get.</p>
<p>Now, if you would instead like to create your own distribution on CPAN, go for it!  Its really quite easy and fun.  But, it is <i>VERY</i> important that you think long and hard about what you want to release on CPAN.  It may seem that every possible task that someone might want to accomplish in Perl is already available on CPAN &#8211; this is false.  I regularly find myself needing tools that aren&#8217;t yet on CPAN.  Don&#8217;t just write something for the sake of getting something on CPAN &#8211; develop something that is useful, of high quality, has a decent suite of automated tests, and doesn&#8217;t duplicate a module that is already on CPAN.</p>
<p>Once you developed a module or two, and you are ready to get it out the door, you&#8217;ll want to do a couple things.  First, create a directory to hold your distribution.  Assuming your module is named Acme::Yesterday:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> Acme-Yesterday<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> Acme-Yesterday<br />
<span style="color: #c20cb9; font-weight: bold;">vi</span> Makefile.PL</div></div>
<p>You&#8217;ll want to install <a href="http://search.cpan.org/perldoc?Module::Install">Module::Install</a> first, before you go any further as it provides a much easier to configure build/test/install process than the old-school <a href="http://search.cpan.org/perldoc?ExtUtils::MakeMaker">ExtUtils::MakeMaker</a>.</p>
<p>Now, your Makefile.PL will look something like this:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">use</span> inc<span style="color: #339933;">::</span><span style="color: #006600;">Module</span><span style="color: #339933;">::</span><span style="color: #006600;">Install</span><span style="color: #339933;">::</span><span style="color: #006600;">DSL</span> <span style="color: #cc66cc;">0.91</span><span style="color: #339933;">;</span><br />
all_from lib<span style="color: #339933;">/</span>Acme<span style="color: #339933;">/</span>Yesterday<span style="color: #339933;">.</span>pm<br />
requires DateTime<br />
test_requires Test<span style="color: #339933;">::</span><span style="color: #006600;">More</span> <span style="color: #cc66cc;">0.42</span></div></div>
<p>(Notice the first line DOES have a semicolon at the end, while the rest do not)</p>
<p>Next, create a directory to put your module(s):</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> lib<br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> lib<span style="color: #000000; font-weight: bold;">/</span>Acme<br />
<span style="color: #c20cb9; font-weight: bold;">vi</span> lib<span style="color: #000000; font-weight: bold;">/</span>Acme<span style="color: #000000; font-weight: bold;">/</span>Yesterday.pm</div></div>
<p>Now, your module will need some minimum requirements such as declaring the version of the distribution, the license type, and a name.  Also, most CPAN modules follow a common convention for documentation using <a href="http://perldoc.perl.org/perlpod.html">POD</a>.  Here is the most minimal of a module:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://perldoc.perl.org/functions/package.html"><span style="color: #000066;">package</span></a> Acme<span style="color: #339933;">::</span><span style="color: #006600;">Yesterday</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">our</span> <span style="color: #0000ff;">$VERSION</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.01</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">=head1 NAME<br />
<br />
Acme::Yesterday - Make time() return the same hour,<br />
second, and even minute as exactly 24 hours ago!<br />
<br />
=head1 SYNOPSIS<br />
<br />
&nbsp; &nbsp; use Acme::Yesterday;<br />
<br />
=head1 DESCRIPTION<br />
<br />
I'm an interesting introduction to this module.<br />
<br />
=cut</span><br />
<br />
<span style="color: #000000; font-weight: bold;">use</span> DateTime<span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">=head1 METHODS<br />
<br />
=head2 some_method<br />
<br />
&nbsp; &nbsp; some_method();<br />
<br />
Description of some_method().<br />
<br />
=cut</span><br />
<br />
<span style="color: #000000; font-weight: bold;">sub</span> some_method <span style="color: #009900;">&#123;</span> <span style="color: #339933;">...</span> <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">=head1 AUTHOR<br />
<br />
Your Name &lt;your@email&gt;<br />
<br />
=head1 COPYRIGHT<br />
<br />
This program is free software; you can redistribute it<br />
and/or modify it under the same terms as Perl itself.</span></div></div>
<p>Alternatively you can use <a href="http://search.cpan.org/perldoc?Module::Starter">Module::Starter</a> to create a shell of a module for you.</p>
<p>Now for automated tests.  At a <em>minimum</em> you should write a test that verifies that your module can even be loaded.  Here&#8217;s how to do that:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> t<br />
<span style="color: #c20cb9; font-weight: bold;">vi</span> t<span style="color: #000000; font-weight: bold;">/</span>00_use.t</div></div>
<p>The content of 00_use.t should be something like:</p>
<div class="codecolorer-container perl vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span><br />
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> Test<span style="color: #339933;">::</span><span style="color: #006600;">More</span> tests <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">BEGIN</span><span style="color: #009900;">&#123;</span> use_ok<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'Acme::Yesterday'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></div></div>
<p>You&#8217;ll need to make a couple more files:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'perldoc Acme::Yesterday'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> README<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'0.01 - First release.'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> Changes</div></div>
<p>OK, now just sit back and let Module::Install do its work:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">perl</span> Makefile.PL<br />
<span style="color: #c20cb9; font-weight: bold;">make</span> dist<br />
<span style="color: #c20cb9; font-weight: bold;">make</span> disttest</div></div>
<p>Assuming your tests pass when you run `make disttest`, you&#8217;re set to put your module on CPAN.  The above steps would have now created for you a Acme-Yesterday-0.01.tar.gz.  This is the file that you need to upload to CPAN.  In order to upload a distribution to CPAN you&#8217;ll need to get a <a href="http://pause.perl.org/pause/query?ACTION=request_id">pause account</a>.  Once your request has been approved you can login to pause, go to the upload page, and upload your tarball.  Within an hour or two your new distribution will be availabe on <a href="http://search.cpan.org">CPAN</a>.</p>
<p>Once you&#8217;ve done this you&#8217;ll want to clean up your distribution directory as running the various make steps leaves around some files you don&#8217;t need:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">make</span> distclean</div></div>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluefeet.net/2009/07/authoring-a-cpan-module/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.707 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-03-10 13:05:40 -->
