On the surface, you've run into a well-known Perl pitfall: Multiple simultaneous array assignments put everything into the first target array, and starve the others. That's an easy problem to solve, but I don't think moving to references is the right approach, because it doesn't address the more subtle structural issue of accidental coupling via get_data().

I think you'll be happier off switching to:

my @network_data = get_network_data(); my @location_data = get_location_data();
rather than than collecting up all of your data and returning it from one function call. The problem with get_data() is that it makes the code brittle. If you later decide to add another type of data, you have to track down all callers of get_data() and teach them that there's another data set in the list of references that get_data() returns. Even if you only call get_data() once, there's still the chance that you'll get the order wrong, since get_data() doesn't provide any clues about the order of the data sets it returns. This hidden order dependency is a form of "coupling", which is a Software Engineering term that generally means "A Bad Thing, Don't Do It."

By having a separate function for each data set, it's easy to add a third without interfering with the first two. Order dependency isn't an issue. This might not be an issue for the current script, but it's something to keep in mind when you find yourself writing something larger.


In reply to Re: HTML::Template Error by dws
in thread HTML::Template Error by ypcat

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.