Not that it makes a huge difference, but why is the default style of programmingFirst 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?
How do you determie easily which element is row X and col Y?my @result = $dbh->fetchall_array(); print Dumper(\@result); $VAR1 = [ R1C1, R1C2, ..., R1Cn, R2C1, R2C2, ..., R2Cn, ..., RnC1, RnC2, ..., RnCn, ];
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |