<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Autovivification bit me today</title>
	<atom:link href="http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/</link>
	<description>... notes, thoughts, rants, and randomness.</description>
	<lastBuildDate>Mon, 08 Apr 2013 21:01:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Jeremy Leader</title>
		<link>http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/comment-page-1/#comment-23354</link>
		<dc:creator>Jeremy Leader</dc:creator>
		<pubDate>Tue, 07 Dec 2010 23:44:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=25#comment-23354</guid>
		<description><![CDATA[What happens if you&#039;ve already called load_hashref earlier, and it loaded an empty hash?  Should you call load_hashref again this time around, or not?

I think that argues for guarding against autovivification, and in favor of distinguishing between 2 different states:

$hashref is defined: means load_hashref has already been called, even if it loaded 0 keys

$hashref is not defined: means load_hashref hasn&#039;t been called yet.]]></description>
		<content:encoded><![CDATA[<p>What happens if you&#8217;ve already called load_hashref earlier, and it loaded an empty hash?  Should you call load_hashref again this time around, or not?</p>
<p>I think that argues for guarding against autovivification, and in favor of distinguishing between 2 different states:</p>
<p>$hashref is defined: means load_hashref has already been called, even if it loaded 0 keys</p>
<p>$hashref is not defined: means load_hashref hasn&#8217;t been called yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aristotle Pagaltzis</title>
		<link>http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/comment-page-1/#comment-22331</link>
		<dc:creator>Aristotle Pagaltzis</dc:creator>
		<pubDate>Sun, 21 Nov 2010 23:09:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=25#comment-22331</guid>
		<description><![CDATA[Even if you stick with &lt;code&gt;keys&lt;/code&gt;, you don’t need &lt;code&gt;scalar&lt;/code&gt;.

But I would add a clause to prevent autovivification instead of permitting an empty hash.

Note that a normal reference can never be a false value, so you don’t really need &lt;code&gt;defined&lt;/code&gt;, just checking for truthiness is fine.

Bottom line, I’d write:

&lt;code&gt;
return if $hashref and $hashref-&gt;{something};
load_hashref $hashref if not $hashref;
&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>Even if you stick with <code>keys</code>, you don’t need <code>scalar</code>.</p>
<p>But I would add a clause to prevent autovivification instead of permitting an empty hash.</p>
<p>Note that a normal reference can never be a false value, so you don’t really need <code>defined</code>, just checking for truthiness is fine.</p>
<p>Bottom line, I’d write:</p>
<p><code><br />
return if $hashref and $hashref-&gt;{something};<br />
load_hashref $hashref if not $hashref;<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: b</title>
		<link>http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/comment-page-1/#comment-27</link>
		<dc:creator>b</dc:creator>
		<pubDate>Thu, 28 May 2009 01:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=25#comment-27</guid>
		<description><![CDATA[I like 

  return if $hashref and exists $hashref-&gt;{something};

much better than counting the keys.]]></description>
		<content:encoded><![CDATA[<p>I like </p>
<p>  return if $hashref and exists $hashref-&gt;{something};</p>
<p>much better than counting the keys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lwsitu</title>
		<link>http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/comment-page-1/#comment-26</link>
		<dc:creator>lwsitu</dc:creator>
		<pubDate>Wed, 27 May 2009 23:44:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=25#comment-26</guid>
		<description><![CDATA[you don&#039;t need to use scalar keys, just using a hash in scalar context would work as well]]></description>
		<content:encoded><![CDATA[<p>you don&#8217;t need to use scalar keys, just using a hash in scalar context would work as well</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Laufeyjarson</title>
		<link>http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/comment-page-1/#comment-25</link>
		<dc:creator>Laufeyjarson</dc:creator>
		<pubDate>Wed, 27 May 2009 20:55:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=25#comment-25</guid>
		<description><![CDATA[I was following the advice from http://www.perlmonks.org/?node_id=173677 which points out that not all tied hashes behave properly in those situations.

In my specific case, it would have been fine, but in the general case it might not always work.]]></description>
		<content:encoded><![CDATA[<p>I was following the advice from <a href="http://www.perlmonks.org/?node_id=173677" rel="nofollow">http://www.perlmonks.org/?node_id=173677</a> which points out that not all tied hashes behave properly in those situations.</p>
<p>In my specific case, it would have been fine, but in the general case it might not always work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/comment-page-1/#comment-21</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Wed, 27 May 2009 15:10:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=25#comment-21</guid>
		<description><![CDATA[you shouldn&#039;t need scalar keys
my $hashref = {};
return if exists $hashref-&gt;{something};
load_hashref($hashref) unless  %$hashref;]]></description>
		<content:encoded><![CDATA[<p>you shouldn&#8217;t need scalar keys<br />
my $hashref = {};<br />
return if exists $hashref-&gt;{something};<br />
load_hashref($hashref) unless  %$hashref;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pedro Melo</title>
		<link>http://blog.laufeyjarson.com/2009/05/autovivification-bit-me-today/comment-page-1/#comment-19</link>
		<dc:creator>Pedro Melo</dc:creator>
		<pubDate>Wed, 27 May 2009 06:42:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=25#comment-19</guid>
		<description><![CDATA[The last line can even be simpler:

    load_hashref($hashref) unless %$hashref;

Best regards,]]></description>
		<content:encoded><![CDATA[<p>The last line can even be simpler:</p>
<p>    load_hashref($hashref) unless %$hashref;</p>
<p>Best regards,</p>
]]></content:encoded>
	</item>
</channel>
</rss>
