in reply to DBI Array of Hashes... simpler way?

DBI gives you the fetchall_arrayref and fetchall_hashref methods which do what you are attempting, though the documentation is unclear to my reading and I haven't worked with them myself.

On a side note, your code will likely fail because (from DBI):

Note that the same array reference is returned for each fetch, so don't store the reference and then use it after a later fetch. Also, the elements of the array are also reused for each row, so take care if you want to take a reference to an element. See also "bind_columns".
  • Comment on Re: DBI Array of Hashes... simpler way?

Replies are listed 'Best First'.
Re^2: DBI Array of Hashes... simpler way?
by ruzam (Curate) on Aug 25, 2009 at 04:09 UTC
    The key word is 'array reference'. I don't believe fetchrow_hashref is subject to this limitation (any more).