Any way that helps you understand is a good one. After all, this is Perl.<grin/>

However, I do have a few suggestions. I find that small utility functions often reduce the difficulty of reading code. For example, you repeat a snippet of code in three places to create a directory. I would probably define:

sub mkdir_if_needed { my ($dir) = @_; return if -d $dir; mkdir($dir,0755) or warn "Could not mkdir: $!\n"; return; }

and then call it in multiple places. That reduces unnecessary noise in the code.

The outer loop can also be done as a Perl foreach loop (instead of the C-style you are using). The beginning of the loop would look like:

foreach my $dacdir ( @allDACDirs ) { my $curr_dir; my $entry; # Read the array and populate foreach $entry (@{$dacdir}) ...

This removes the need for $array_no and $i.

A minor step into a more complex data structure would be to replace the strings above with anonymous arrays, so you don't spend time reparsing. I would have made the following replacements in the first array:

This is mostly because I tend to think in these kinds of structures. I might then suggest different characters for the two styles of f entries. One would not have the extra file entry and the other would.

This might tempt me toward a more table-driven approach for processing the entries... But, I'll stop here before the abstraction level gets too deep (and we have to break out the hip-waders<grin/>).

G. Wade

In reply to Re: How would you handle arrays of arrays? by gwadej
in thread How would you handle arrays of arrays? by gokuraku

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.