On Sat, Dec 29, 2001 at 09:33:30PM -0800, Bill Moseley wrote:
> At 12:20 AM 12/30/01 -0500, Gyepi SAM wrote:
> >Off topic, but that for loop could use some trimming
> >#Watch out for those 'magic' numbers!
> >for (my $x = 0; $x < 5; $x++){
> > $qrefs[$x] = $qry->fetchrow_hashref();
> >}
>
> How about:
>
> my @qrefs = map { $qry->fetchrow_hashref } 1..5;
>
> Or you you live in the future:
>
> my @qrefs = map { { %{$qry->fetchrow_hashref} } } 1..5;
That would work. Though to be honest, I would probably not do either and use
the database LIMIT clause (or equivalent). Depending on the query and the
database client library implementation, one may end up fetching a lot of
data, only to through most of it away. Obviously, this all depends on what
else you need to do with the data. Sometimes you do want to fetch a huge
amount of data!
-Gyepi
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]