<?xml version="1.0" encoding="windows-1252"?>
<node id="35311" title="Re: varying length multi-dimensional hashes" created="2000-10-04 19:05:54" updated="2005-07-19 14:08:39">
<type id="11">
note</type>
<author id="11332">
c-era</author>
<data>
<field name="doctext">
I don't think this is the best way to do it, but it sure was fun to write:
&lt;code&gt;
my $eval;
my %hash;

# Find all three letter occurences, and combine them into one eval statment.
while (&lt;&gt;){
	$eval = '$hash ';
	while (/(...)/g){
		$eval .= "{'$1'}"
	}
	$eval .= "++;"
	eval ($eval); # You should probably do some error checking at this point.
}
for (keys %hash){
	hashValue ($hash{$_});
}

# You got to love recursive functions ;)
sub hashValue {
	my $hash = @_[0];
	if (defined %$hash){
		for (keys %$hash){
			hashValue ($$hash{$_});
		}
	} else {
		print $hash; # Or do whatever you like with the value
	}
}
&lt;/code&gt;</field>
<field name="root_node">
35303</field>
<field name="parent_node">
35303</field>
</data>
</node>
