I'll likely end up with three different name-value strings (in the standard "name=value&name=value" form). I want to access all this data through a CGI object, *but* I'd like GET data to take precedence over POST data, which should take precedence over cookie data, and I can't be sure of the results of just joining them and passing the result to new CGI($str).
So basically, I want to Thus if I end up with these values:
I need to merge them into this:$cookie = "user=john&pass=bleh&sort=descending"; $post = "pg=2&col=3&row=4"; $get = "pg=1&sort=ascending";
Is there an obvious and/or more efficient way to do this that doesnt require breaking everything down into hashes and processing it all several times (because these strings may get very large)?$str = "user=john&pass=bleh&pg=1&col=3&row=4&sort=ascending";
Addendum: Basically, I know i could split into an array on '&', and then split each element on '=' into hash keys/values, and do cookie, post, get (so newer vals overwrite existing vals), but is there a better way?
__________
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
- Terry Pratchett
In reply to merging multiple name-value pairs (with precedence) by EvanK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |