Greetings,
I�m trying to generate a tree of nested hashes [of an
arbitrary size].
Perhaps you could suggest a better solution.
Currently I'm trying to use symbolic references
according to the literature� but without much luck.
Best regards,
David
My script is as follows (for now, I�ve tried to keep
the tree as simple as possible):
#!perl
#use strict;
# Currently commented-out because of warning: "Can't
use string ("1") as a SCALAR ref".
use warnings;
use Data::Dumper;
my ($href, %Tree, $cluster_id, $split_val, $num_child,
$i, $j, $k);
$href = \%Tree;
$cluster_id = 698;
$split_val = 1;
$num_child = 2;
# For now, the above values are arbitrary
place-holders.
$i = 0;
$j = 1;
while ($i<4) {
$$i = {
ClusterNum => $cluster_id,
SplitValue => $split_val,
NumChildren=> $num_child,
Child => $$j,
# �Child� value should be a reference to the
subsequent hash.
};
if ($i==0) {
$Tree{Root} = \$$i;
next;
}
$k = ($i - 1);
$$k = \$$i;
$i = ($i + 2);
$j = ($j + 2);
}
print Dumper($href)."\n";
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>