First, I can't say how amazing that all of you made time to answer my questions. Without you guys/gals, I probably wouldn't have a job, right now.

Here's how I solved it:

- Each config file has an accompanying ".hosts" file, whose contents are the hostnames of each machine in the cluster.
- Hosts 1-6 are contained on config_file.hosts
- Host 7 is contained in dnsfile_file.hosts

I have two hashes that I refer to in the code.

- %config_files - Keys = cluster directory, Value = an array ref to a list of each config file associated with that cluster.

- %config_params - Keys = config_file, Value = an array ref to a list containing config_file, config_file.hosts, user|preprocess.pl, user|postprocess.pl, and a file "weight"

foreach $componentDir ( keys %config_files ) { $abs_cluster_dir = join("/", "$configdir", "$componentDir"); @cluster_files = @{ $config_files{ $componentDir } }; $href_cluster_files = \@cluster_files; &process_cluster( $abs_cluster_dir, \@cluster_files, \%config_params, \$err_msg ); } sub process_cluster { # subroutine parameters my $cluster_dir = $_[ 0 ]; my $aref_cluster_files = $_[ 1 ]; my $href_config_params = $_[ 2 ]; my $sref_err_msg = $_[ 3 ]; my $clusterHost; my $config_file; my $counter; my $file; my @files_to_process; my $hosts_file; my @target_hosts; $counter = 0; foreach $file ( @{ $aref_cluster_files } ) { if (defined ( $href_config_params->{ $file } )) { $files_to_process[ $href_config_params->{ $file }[ 3 ]] = $f +ile; } } foreach $config_file ( @files_to_process ) { $hosts_file = new IO::File ( "$abs_cluster_dir/$config_file.host +s" );print "Hosts file = $hosts_file\n"; unless ( defined ($hosts_file )) { $$sref_err_msg = $!; return 0; } $counter = 0; while ( ! $hosts_file->eof() ) { $target_hosts[ $counter ] = ( $hosts_file->getline( ) ) ; chomp @target_hosts; $counter++; } $hosts_file->close( ); foreach $clusterHost ( @target_hosts ) { ####DO STUFF#### } }
The trick here, is to assign a numerical weight to each file that I need to process, so that I can populate an array of config files in the order that I need to process them!!!

Again, thanks to you all, I began to consider alternatives.

Steve


In reply to Here's what I did: by Tuna
in thread Data Structure Design by Tuna

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.