<?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>The Pythian Blog &#187; Task::BeLike</title>
	<atom:link href="http://www.pythian.com/news/tag/taskbelike/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pythian.com/news</link>
	<description>News and views from Pythian DBAs</description>
	<lastBuildDate>Thu, 29 Jul 2010 15:23:33 +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>Perl Module Dependencies: how to require the latest, and nothing less</title>
		<link>http://www.pythian.com/news/4281/perl-module-dependencies-how-to-require-the-latest/</link>
		<comments>http://www.pythian.com/news/4281/perl-module-dependencies-how-to-require-the-latest/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 20:25:59 +0000</pubDate>
		<dc:creator>Yanick Champoux</dc:creator>
				<category><![CDATA[Not on Homepage]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[CPAN]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[hanekomu]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Task::BeLike]]></category>
		<category><![CDATA[Task::BeLike::YANICK]]></category>

		<guid isPermaLink="false">http://www.pythian.com/news/?p=4281</guid>
		<description><![CDATA[Recently, hanekomu was contemplating how to make subsequent installs of a Task::BeLike module upgrade its dependencies to their latest version. This gave me ideas... ]]></description>
			<content:encoded><![CDATA[<p>Recently, hanekomu was contemplating <a href="http://hanekomu.at/blog/dev/20091005-1227-repeatedly_installing_task_distributions.html">how to make subsequent installs of a <em>Task::BeLike</em> module upgrade its dependencies to their latest version</a>.</p>
<p>The idea is intriguing.  It&#8217;s not something you want to do for a typical module, but it makes sense in the context of <em>Task::BeLike</em>. If you care enough about a module to put it in your <em>Task::BeLike</em>, you probably care enough to want to upgrade when there&#8217;s a new version out there.</p>
<p>Alas, I think hanekomu&#8217;s proposed way of doing it is flawed (mind you, the debate is still going on as of the writing of this entry, and I can very well still be proven wrong).  But after some pondeferous chin scratching, I might have come with a cunning alternative to it.</p>
<p><span id="more-4281"></span></p>
<p>Let&#8217;s say that in your <code>Build.PL</code> (the logic would be the same for a <code>Makefile.PL</code>) you have your dependencies stashed in <em>%dependencies</em>.  Something akin to:</p>
<pre><code>%dependencies = (
    XML::LibXML      =&gt; 0,          # any version will do
    XML::XPathScript =&gt; '1.42',     # 1.42 or higher
    Moose            =&gt; 'latest',   # nothing but the shiniest!
);
</code></pre>
<p>All we want to do, really, is to switch the <em>latest</em> for, well, the latest version available.  Surprisingly, that something that is almost as easy to do than to say:</p>
<pre><code>for my $mod ( keys %dependencies ) {
    next unless $dependencies{$mod} eq 'latest';

    require CPANPLUS::Backend;
    state $cb = CPANPLUS::Backend-&gt;new;

    $dependencies{$mod} = $cb-&gt;module_tree( $mod )-&gt;package_version;
}
</code></pre>
<p>Yes, that&#8217;s really all there is to it. A <a href="http://github.com/yanick/Task-BeLike-YANICK/commit/563898785d5a39af66c6d5ad3a296dfb7568bb3e">little further hacking</a> later, I have incorporated the functionality to my own <em>Task::BeLike::YANICK</em> module.  The way I implemented it, installing the module the usual way will yield no surprise (i.e., dependencies already present are not going to be updated).  But if the environment variable <code>TASK_UPGRADE</code> is set to true, like so:</p>
<pre><code>TASK_UPGRADE=1 cpan -f Task::BeLike::YANICK</code></pre>
<p>&nbsp;.&nbsp;.&nbsp;.&nbsp;then the magic is going to be unleashed (the <code>-f</code> is to force the re-install, if the Task has already been installed before).</p>
<p>Alternatively, just to know which dependencies are out-of-date, one can also extract the distribution and do a</p>
<pre><code>perl ./Build.PL --upgrade
./Build prereq_report
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.pythian.com/news/4281/perl-module-dependencies-how-to-require-the-latest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
