In case it's of interest here is my final version of my function to print the data in each of my n-ary tree nodes:
# A) From an initializing function for nary tree nodes:
# My hash variable
my %node_data;
# Put data in hash
$node_data{"dir_name"} = "/vobs/engine_cdma2000/code/dmss/apps/MediaPl
+ayer";
$node_data{"dir_vep"} = "/vobs/engine_cdma2000/code/dmss/apps/MediaPla
+yer@@/main/par_x_haloc9_s74.47.9/bld_01.06.00_ca25_krmt43_haloc/1";
# Pass hash by reference to new()
$root = Tree::Nary->new(\%node_data);
# B) Final version of my print nary tree function:
sub print_nary_dir_tree {
my $tree = shift;
my $printsub = sub {
my $node = shift;
my %hash_data;
if (defined $node) {
# Reference to a hash
my $node_data = $node->{data};
# The hash itself
%hash_data = %$node_data;
if (defined $node_data) {
print "hash_data dir_name holds $hash_data{dir_name}\n";
print "hash_data dir_vep holds $hash_data{dir_vep}\n";
} else {
print "printsub if statement has failed\n";
}
}
return 0;
};
|