NerfMan has asked for the wisdom of the Perl Monks concerning the following question:
The quick version:
Can I get the values of a hash in a given order without walking the hash?
The full story:
I have the results of a query in a hash via bound columns (a la http://www.perl.com/lpt/a/521)
I need to send some of those fields to a stored procedure on the db server in a particular order.
I have an array of the fields names I want (and in the correct order).
I know I can do something like this:
But is there a slicker, faster way?foreach $key (@field_names) { push @request, $results{$key} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Order hash results
by ikegami (Patriarch) on Aug 24, 2009 at 16:25 UTC | |
|
Re: Order hash results
by Marshall (Canon) on Aug 24, 2009 at 18:28 UTC | |
|
Re: Order hash results
by ganeshk (Monk) on Aug 25, 2009 at 02:56 UTC | |
|
Re: Order hash results
by NerfMan (Initiate) on Aug 25, 2009 at 14:28 UTC |