In glancing through the code, if appears that something in or around the line in sub _get_reports()
$problem .= "$site_folder ";

would have to be involved. Expanding the search out from that point I see that the array  @site_array is being looped over and that $problem is being reset just before it. Hmmm, that seems Ok.

Branching out to the next loop I see that @site_array is initialized before the outer loop (which walks thru the reports) and not always within the loop.

I think that is the problem. The @site_array array is initialized differently depending on  $site_locations. In the 'All' case new sites are pushed onto the array leading to an accumulation of the sites and the problem you are seeing. So, I think you need to clear the array in that case.

if ($site_locations eq 'All') { @site_array = (); #clear the array for my $site (sort keys %$sites) { push @site_array, $site; } ...

I have not tested this, it's just my first guess. I hope it helps.

FWIW: My litte Rant; I used to produce "Write-Only" code until I had to debug some crap I "Wrote" in the past and did not have the faintest clue what I had done or why. I comment code now! :-))


In reply to Re: Copying Reports from Multiple Sites by knexus
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.