http://qs321.pair.com?node_id=215475


in reply to Sorting hash values according to order of an array

As an alternative to tadman's solution, you could also use a hash slice, like so:

# Everything else is the same as your original code $sth->execute(@{$q{'-values'}}{@{$TABLES{$q{'-table'}}}}); # Or, a little more readably using temp vars: my $table = $q{'-table'}; my @columns = @{$TABLES{$table}}; my %values = %{$q{'-values'}}; $sth->execute(@values{@columns});

bbfu
Black flowers blossum
Fearless on my breath

  • Comment on (bbfu) (hash slice) Re: Sorting hash values according to order of an array
  • Download Code