Not that it makes a huge difference, but why is the default style of programming
First of all, there's nothing in DBI docs that says that the default style programming is to use references. It's a general advice in Perl, and highly recommended, to use references when passing parameters and returning values to minimize memory usage (for one goal).
I'm just trying to puzzle out if there's any advantage.
Another advantage in using references is to build complex data structure in more flexible way, regarding above about passing parameters and returning values. And it also happens to have something to do with your bonus question.
Bonus question -- why is there a fetchall_arrayref() but not a simple fetchall_array()?
At the first impression, by fetchall_array() I think you mean that you want all rows and columns are returned in a big one-dimension array. Think about it, do you really want this returned to you?
my @result = $dbh->fetchall_array(); print Dumper(\@result); $VAR1 = [ R1C1, R1C2, ..., R1Cn, R2C1, R2C2, ..., R2Cn, ..., RnC1, RnC2, ..., RnCn, ];
How do you determie easily which element is row X and col Y?

At the second thought, if the result you wanted was actually one column per row, then you'd need a different method, and you'd get the one-single array you wanted. See my other reply for how to do it.

Now, if this satisfied you, would you think that replying a bonus question deserved a bonus reward? ;-)

Update: Fixed typo on the imaginary fetchall_array method name (was fethcall_array). Thanks holli :-)


Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


In reply to Re: Why a reference, not a hash/array? by naikonta
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.