<?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>SciTools Blog &#187; perl</title>
	<atom:link href="http://scitools.com/blog/tag/perl/feed" rel="self" type="application/rss+xml" />
	<link>http://scitools.com/blog</link>
	<description>Maintain your Software</description>
	<lastBuildDate>Mon, 30 Jan 2012 19:15:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Changes to the Perl API</title>
		<link>http://scitools.com/blog/2009/04/changes-to-the-perl-api.html</link>
		<comments>http://scitools.com/blog/2009/04/changes-to-the-perl-api.html#comments</comments>
		<pubDate>Thu, 09 Apr 2009 14:16:15 +0000</pubDate>
		<dc:creator>KevinG</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Scitools Labs]]></category>
		<category><![CDATA[Understand 2.0]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://scitools.com/blog/http:/scitools.com/blog/archives/2009/04/changes-to-the-perl-api.html</guid>
		<description><![CDATA[We&#8217;ve made several changes to the Understand Perl API recently. The largest change was upgrading from Perl 5.6.0 to 5.10.0 in build 473.
In addition to several cool new features like the smart match operators and switch statements, Perl 5.10 runs faster and has a smaller memory footprint. For more details on what the changes are [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve made several changes to the <em>Understand</em> <a href="http://www.scitools.com/products/understand/perl.php">Perl API</a> recently. The largest change was upgrading from Perl 5.6.0 to 5.10.0 in build <a href="http://scitools.com/blog/2009/03/understand-20-build-notes-b473.html" target="_blank">473</a>.<br />
In addition to several cool new features like the smart match operators and switch statements, Perl 5.10 runs faster and has a smaller memory footprint. For more details on what the changes are and how to use<br />
them, see the <a href="http://dev.perl.org/perl5/news/2007/perl-5.10.0.html" target="_blank">Perl 5.10 Release Announcement</a>.</p>
<p>We are also in the process of adding Snapshot support for the Perl API for build 476. Now you can access historical versions of the code through your scripts as well. For example you can compare versions of files or write a script to compare metrics between versions. <span id="more-395"></span><strong> </strong></p>
<p><strong>What does this mean to you as an <em>Understand</em> script user?</strong><br />
In addition to the new features, the main side effect might be that some scripts might no longer work.</p>
<p>If any of your scripts stop working, review this list of incompatabilites in the <a href="http://search.cpan.org/dist/perl-5.10.0/pod/perl5100delta.pod#Incompatible_Changes/">Perl delta document</a>. You can also make sure the scripts are still valid syntax by running <strong>maintain_uperl -c myscipt.pl</strong>.</p>
<p>The new snapshot changes modify the API in a few different ways:</p>
<ul>
<li> Db::snapshots() to get a list of snapshots for the db.</li>
<li>$snapshot-&gt;name() to get the name of a snapshot and</li>
<li>$snapshot-&gt;open() to open the snapshot and return a $db variable that represents the snapshot.</li>
<li>The $db object is now &#8220;live&#8221;. It never used to be and it was never important that a script pass around and use the correct object. It is now critical.</li>
<li>Entity objects carry with them knowledge of the database/snapshot they belong to. Multiple databases/snapshots can be open and you can have entities from them all at once.</li>
<li>Any <strong>scripts which used entity ids <em>$ent-&gt;id() </em>as keys in hashes must be updated</strong> &#8211; the $ent-&gt;id is no longer unique across snapshots and multiple databases
<ul>
<li><span style="text-decoration: line-through;">At the beginning of the script add:   <em>use Tie::RefHash;</em></span></li>
<li><span style="text-decoration: line-through;">declare the hash with:  <em>tie my %my_hash, &#8216;Tie::RefHash&#8217;;</em></span></li>
<li><span style="text-decoration: line-through;">use the actual entity object as the key <em>$my_hash{$ent}</em>, not the dereference of the entity <em>$my_hash{$ent-&gt;id}</em>.</span></li>
<li><span style="text-decoration: line-through;">Don&#8217;t use Understand::ent-&gt;new($id) to reconstruct an Ent object from the id.</span></li>
</ul>
</li>
</ul>
<p>If you run into any problems that you need help with, feel free to post a question on the <a href="http://www.scitools.com/support/forum/viewforum.php?f=5" target="_blank">scripting forum</a>, or shoot us an email at support@scitools.com</p>
<p>UPDATE- We found some issues with the above approach to $ent-&gt;id and changed it with build 477. Using a Tie::RefHash for entities does not work as intended and is no longer recommended. We added a new call $db-&gt;<strong>ent_from_id</strong>($id), to reconstruct entity objects from ids.  To use entities as hash keys without later retrieving the entities from keys, it is sufficient to simply use $ent for the key. To later retrieve an entity from a key, instead, use the entity id as the key ($ent-&gt;id()), and retrieve the entity from the key with $db-&gt;ent_from_id($key). Note, it is not possible to safely store entities from different db&#8217;s into the same hash using this technique, since id&#8217;s are not unique across multiple open db&#8217;s.</p>
]]></content:encoded>
			<wfw:commentRss>http://scitools.com/blog/2009/04/changes-to-the-perl-api.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

