I came to the same opinion as knexus, that the problem is around

<coded>$problem .= "$site_folder ";</code>

But tracing how I got there shows a couple other poor coding areas, improving which might improve debugging ability.

I began by searching the program for The following files were not copied over properly:. It turns out to be in _print_report(), followed by printing the keys and values of %$missed_reports. remeber for later, the error is associated with the values in the hash..

In the last two lines of code, $missed_reports is passed to _print_report(), obtained from _get_reports().

Near the bottom of _get_reports(), we find:

$problem .= "$site_folder "; $missed_reports{$_} = $problem;

So the question is, what are $site_folder and $_?

The inner loop sets $site_folder as the elements of $site_array, which is populated at the top of the outer loop. And $_ is set by the outer loop.

Pheeeww, huff, puff; that was a long trail ....

Using $_ as the default loop control variable is occassionally convenient because it avoids one variable.... and especially when there are some operators or functions which accept the default variable.

In this case, the default status is not used: $_ is used as an ordinary variable; that outer loop over which $_ appears is quite large---30 lines. So there is no advantage to using $_; instead, it serves as a counter-documentation, minimizing comprehensability of this variable.

Of course, code grows. You start off with something that was going to be short and to the point, and several specification changes later it has become a behemoth. That's why I generally avoid using default variables except in things like one-line map or grep constrructs, or in tiny programs. In any program ( as opposed to short script ), I consider whether anything is gained by anonymous brevity that is a significant improvement over a self-documenting variable name.

--
TTTATCGGTCGTTATATAGATGTTTGCA


In reply to Re: Copying Reports from Multiple Sites by TomDLux
in thread Copying Reports from Multiple Sites by PrimeLord

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.