>Perl's hashes do their own thing with ordering, so unless you do something
like (sort keys %hash)
>you will get what you get.

Yes, but tieing the hash while creating it, in my case with Tie::IxHash,
should preserve the inesertion order.
That works with for example
tie %hash, 'Tie::IxHash';
%hash = ("one"=>"1", "two"=>"2", "three"=>"3");
But not when I create an array of hashes using DBIx::Recordset like below:
________________
use Tie::IxHash;
use DBIx::Recordset;

...sub execute {
tie %main::set, 'Tie::IxHash';
*main::set = DBIx::Recordset->Search({('!DataSource' => $db,
'!Table'      => $table,
'$fields'     => $joined_col,
'$where'    => $query,
'$max'       => 10)});
....
}________________

Marcus

Ged Haywood wrote:

> Hi there,
>
> On Wed, 13 Mar 2002, Marcus Claesson wrote:
>
> > How do I succesfully preserve the column order (''$fields'=>
> > $joined_col') in my array-of-hashes generated using DBIx::Recordset?
>
> Check out a Perl tutorial or the Camel book.  Perl's hashes do their own
> thing with ordering, so unless you do something like (sort keys %hash)
> you will get what you get.  Arrays can preserve sequences but involve
> you in more coding much of the time.
>
> 73,
> Ged.

Reply via email to