Hi All -- If you have time I would appreciate very much if you might answer the following questions about Tree::Nary.

1) I would like to create Tree::Nary nodes whose "data" field is a hash containing information on Clear Case versions of directories and files.

At present I have 2 strings in this hash:
my %node_data;
$node_data{dir_name} = "/vobs/engine_cdma2000/code/dmss/apps/MediaPlayer";
$node_data{dir_vep} = "/vobs/engine_cdma2000/code/dmss/apps/MediaPlayer@@/main/par_x_haloc9_s74.47.9/bld_01.06.00_ca25_krmt43_haloc/1";
$root = Tree::Nary->new(%root_node_data);
B) When I try to print contents of a hash "data" item, in my Tree::Nary node, with this function I have problems:
sub print_nary_dir_tree {
my $tree = shift;
my $printsub = sub {
my $node = shift;
my %node_data = $node->{data};
if(defined $node){
print "node_data dir_name holds $node_data{dir_name}\n";
print "node_data dir_vep holds $node_data{dir_vep}\n";
} return 0;
};

$tree->traverse($tree,
$Tree::Nary::IN_ORDER,
$Tree::Nary::TRAVERSE_ALL,
-1,
$printsub
);
}
~/builds/HALOC9_X_01.06.00R_NARY > nary_tree_testing.pl
Odd number of elements in hash assignment at nary_tree_testing.pl line 196.
Use of uninitialized value in concatenation (.) or string at nary_tree_testing.pl line 198.
node_data dir_name holds
Use of uninitialized value in concatenation (.) or string at nary_tree_testing.pl line 199.
node_data dir_vep holds

Can you let me know the proper way to print out contents of a Tree::Nary data field, if it is a hash?

2) I need to load a Tree::Nary tree with nodes that represent a number of Clear Case versions of directories. first few lines of my input file would look like this:
/vobs/engine_cdma2000/code/dmss
/vobs/engine_cdma2000/code/dmss/apps
/vobs/engine_cdma2000/code/dmss/apps/MediaPlayer

N-ary tree would look like this:

vobs

engine_cdma2000

code

dmss

apps

MediaPlayer

Can you suggest a good algorithm?

I was thinking of tokenizing each directory version and putting each dir it contains in an array

Each node would hold the "dir_name" it represents, example "/vobs/engine_cdma2000/code/dmss"

My algorithm for processing "/vobs/engine_cdma2000/code/dmss"

A) Is "/vobs/" in tree?, if not initialize tree with "/vobs/" node as root

B) Is "/vobs/engine_cdma2000/" in tree?, if not make engine_cdma2000 the child of the latest found directory node, "/vobs"

C) Is "/vobs/engine_cdma2000/code" in tree?, if not make "code" the child of the latest found directory node, "/vobs/engine_cdma2000"

D) Is "/vobs/engine_cdma2000/code/dmss" in tree?, if not make "dmss" the child of the latest found directory node, "/vobs/engine_cdma2000/code"

3) Once N-ary tree of directory versions is loaded I must use this tree to divide the directories into groups, to be dealt with on parallel processes.

The tree must be disassembled into smaller such trees, with one or more such trees being assigned to a group, such that if a given directory is in the input file of directories, all subdirectories of it must be in the same group.

I need to copy these directories from a developer branch to a core branch, and I cannot allow "super" directory X and subdirectory Y to be in separate groups, because this risks having a failed attempt to copy a new subdirectory Y to the core branch BEFORE "super" directory X -- directory X is what gives visibility to a newly created subdirectory Y.

This is an even harder problem than the original Tree:Nary Tree creation, but I would appreciate any hints you might give.

Thanks,
Amphiaraus

In reply to Tree::Nary n00b has questions by Amphiaraus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.