>> my @ids_ary = [];
>> my @names_ary = [];
>> my @age_ary   = [];
>
> Why do you need an empty arrayref as the first element of these?

*** Really don't.  Just habit from 20 years of C programming.  I also
pre-initialize scalars.  Helps me read the stuff 6 months later.

>
> here's an alternative:
>
>   sub iID(){0} sub iNAME(){1} sub iAGE(){2}
>   my @IdNameAge_pary = ( [],[],[] );
>   while (my ($id,$name,$age) = @{$sth->fetch}){
>      push @{$IdNameAge[iID]},$id;
>      push @{$IdNameAge[iNAME]},$name;
>      push @{$IdNameAge[iAGE]},$age;
>   };

Perl is wonderful.  There are so many ways to do things.  You are
clearly a more experienced and knowlegeable perl programmer than I.
I would not be able to read this 6 months later.

>   ...
>
>
> but seriously, loading everything into a temporary array just uses a
> lot of memory and makes the code larger, so I avoid it when I can.
> DBI's facility for providing a hashrefs for every result row makes it
> easy to use names not numbers,

*** This is what I use.  In fact, in 2 years of writing my own app, I have
never used fetchrow_array once!  Only fetchrow_hashref().  But the original
poster wasn't asking about that.

Perl's motto:  "There's More Than One Way To Do It"

Jerry's one-man-project motto: "You Don't Have To Learn The Other Way".


                                - Jerry Kaidor


Reply via email to