in reply to HTML::Template Error

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.

Replies are listed 'Best First'.
Re^2: HTML::Template Error
by ypcat (Beadle) on Jul 24, 2004 at 19:57 UTC
    Thank You both very much. I just realized how silly I am. I am aware of multiple lists when being returned being flattend. I just managed to oversite it at 5 in the morning + I was convince there was something going on with HTML::Template so I didn't even bother to realize. It's clear and day now and the issue has been resolved. I used 2 different sub routine's to return the 2 queries and now everything is peachy.

    Thanks Again,
    YpCat