![]() |
|
No such thing as a small change | |
PerlMonks |
Sorting hash values according to order of an arrayby mt2k (Hermit) |
on Nov 24, 2002 at 01:45 UTC ( [id://215458]=perlquestion: print w/replies, xml ) | Need Help?? |
mt2k has asked for the wisdom of the Perl Monks concerning the following question:
Okay, I am working on a function that inserts a row into a MySQL table. Now, I am trying to make this thing slightly intelligent. So I have a hash that looks like the following:
Next I have a subroutine in my module that is called like the following:
Next comes the part I am having problems with. Here is a sample part that is close to that of my subroutine:
If you didn't catch on immediately, the problem lies in the fact that I am supplying the values of the hash to execute(). This means they are not in the correct order that MySQL requires them to be in. This is where the %TABLES hash comes in. This hash contains the arrays that hold the correct order in which the values must be passed as placeholders in the execute() statement. So what I need to do is take the values of %{$q{'-values'}} and return them sorted in the correct order as identified by %TABLES. I hope I've been clear enough in order to recieve some answers to this question which has perplexed me. Thanks in advance!
Back to
Seekers of Perl Wisdom
|
|