Essentially, you're worried about details you don't need to worry about. At a guess, when you do an "execute", the information isn't loaded into perl's memory yet, but rather will (usually) be sitting in a buffer inside the database itself. Once you do a "fetchall" of some sort, then the entire result set is definitely loaded into perl's memory, and for efficiency's sake what you want is to get a reference to that datastructure, you don't want to make a second copy of it just to save you from thinking about references.

You understand, that when you do a:

$working_href = $returned_href;
that's just making a copy of a scalar value, but if you do a:
%working = %returned;
that makes a copy of the entire data-structure. That doubles you memory usage, and wastes time in making the copy... so you don't want to do that unless you have a really good reason (like you're planning on modifying the copy and you need to preserve the original).

By the way, if you need to join an array given a reference to it, you just do this:

my $string = join " ", @{ $aref };
There's no "extra step" you need to do.


In reply to Re^3: Why a reference, not a hash/array? by doom
in thread Why a reference, not a hash/array? by Cody Pendant

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.